extra: clear hard max if we are falling back to the type max on loops
[smatch.git] / smatch_files.c
blob163a07faa9e1e5af2e40d4a9e967c3b099c344b9
1 /*
2 * sparse/smatch_files.c
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include <string.h>
11 #include <fcntl.h>
12 #include <unistd.h>
13 #include "parse.h"
14 #include "smatch.h"
16 static int open_file(const char *filename)
18 int fd;
19 char buf[256];
21 fd = open(filename, O_RDONLY);
22 if (fd >= 0)
23 goto exit;
24 if (!data_dir)
25 goto exit;
26 snprintf(buf, 256, "%s/%s", data_dir, filename);
27 fd = open(buf, O_RDONLY);
28 exit:
29 return fd;
32 struct token *get_tokens_file(const char *filename)
34 int fd;
35 struct token *token;
37 if (option_no_data)
38 return NULL;
39 fd = open_file(filename);
40 if (fd < 0)
41 return NULL;
42 token = tokenize(filename, fd, NULL, NULL);
43 close(fd);
44 return token;