summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-06 18:12:15 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-01-01 14:34:57 -0800
commit84f5fee3c769fc907c561110f4828416f921e81a (patch)
tree2da192cf588e5c7f93535b7d66e606e83df04a38
parent40bcc8c3303a858c786f1d6d04ae5bbdec6b04ff (diff)
Handle some implicit conversion warnings from clang
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--cppsetup.c10
-rw-r--r--def.h2
-rw-r--r--include.c10
-rw-r--r--main.c2
-rw-r--r--parse.c8
-rw-r--r--pr.c4
6 files changed, 18 insertions, 18 deletions
diff --git a/cppsetup.c b/cppsetup.c
index 90d5eaa..d697730 100644
--- a/cppsetup.c
+++ b/cppsetup.c
@@ -39,14 +39,14 @@ static const char *
my_if_errors(IfParser *ip, const char *cp, const char *expecting)
{
struct _parse_data *pd = (struct _parse_data *) ip->data;
- int lineno = pd->filep->f_line;
+ long lineno = pd->filep->f_line;
const char *filename = pd->filename;
char prefix[300];
- int prefixlen;
- int i;
+ long prefixlen;
+ long i;
- snprintf(prefix, sizeof(prefix), "\"%s\":%d", filename, lineno);
- prefixlen = strlen(prefix);
+ snprintf(prefix, sizeof(prefix), "\"%s\":%ld", filename, lineno);
+ prefixlen = (long) strlen(prefix);
fprintf(stderr, "%s: %s", prefix, pd->line);
i = cp - pd->line;
if (i > 0 && pd->line[i - 1] != '\n') {
diff --git a/def.h b/def.h
index 34bc767..c5a5830 100644
--- a/def.h
+++ b/def.h
@@ -115,7 +115,7 @@ struct inclist {
struct inclist **i_list; /* list of files it itself includes */
struct symtab **i_defs; /* symbol table for this file and its
children when merged */
- int i_listlen; /* length of i_list */
+ unsigned int i_listlen; /* length of i_list */
int i_ndefs; /* current # defines */
boolean *i_merged; /* whether we have merged child
defines */
diff --git a/include.c b/include.c
index 38e3cd0..b3a17ab 100644
--- a/include.c
+++ b/include.c
@@ -178,13 +178,13 @@ included_by(struct inclist *ip, struct inclist *newfile)
ip->i_merged = mallocarray(ip->i_listlen, sizeof(boolean));
}
else {
- for (int i = 0; i < ip->i_listlen; i++) {
+ for (unsigned int i = 0; i < ip->i_listlen; i++) {
if (ip->i_list[i] == newfile) {
- i = strlen(newfile->i_file);
+ size_t l = strlen(newfile->i_file);
if (!(ip->i_flags & INCLUDED_SYM) &&
- !(i > 2 &&
- newfile->i_file[i - 1] == 'c' &&
- newfile->i_file[i - 2] == '.')) {
+ !(l > 2 &&
+ newfile->i_file[l - 1] == 'c' &&
+ newfile->i_file[l - 2] == '.')) {
/* only bitch if ip has */
/* no #include SYMBOL lines */
/* and is not a .c file */
diff --git a/main.c b/main.c
index 58178db..1c378e6 100644
--- a/main.c
+++ b/main.c
@@ -593,7 +593,7 @@ getnextline(struct filepointer *filep)
char *p, /* walking pointer */
*eof, /* end of file pointer */
*bol; /* beginning of line pointer */
- int lineno; /* line number */
+ long lineno; /* line number */
/*
* Fake the "-include" line files in form of #include to the
diff --git a/parse.c b/parse.c
index 9727508..d1b67b6 100644
--- a/parse.c
+++ b/parse.c
@@ -31,7 +31,7 @@ static int deftype(char *line, struct filepointer *filep,
int parse_it);
static int zero_value(char *filename, char *exp, struct filepointer *filep,
struct inclist *file_red);
-static int merge2defines(struct inclist *file1, struct inclist *file2);
+static boolean merge2defines(struct inclist *file1, struct inclist *file2);
static int
gobble(struct filepointer *filep, struct inclist *file,
@@ -260,7 +260,7 @@ fdefined(const char *symbol, struct inclist *file, struct inclist **srcfile)
symbol, file->i_file, (*val)->s_value));
if (val == NULL && file->i_list) {
struct inclist **ip;
- int i;
+ unsigned int i;
for (ip = file->i_list, i = 0; i < file->i_listlen; i++, ip++) {
if (file->i_merged[i] == FALSE) {
@@ -447,13 +447,13 @@ slookup(const char *symbol, struct inclist *file)
return (NULL);
}
-static int
+static boolean
merge2defines(struct inclist *file1, struct inclist *file2)
{
if ((file1 == NULL) || (file2 == NULL) || !(file2->i_flags & FINISHED))
return 0;
- for (int i = 0; i < file2->i_listlen; i++)
+ for (unsigned int i = 0; i < file2->i_listlen; i++)
if (file2->i_merged[i] == FALSE)
return 0;
diff --git a/pr.c b/pr.c
index db2bd34..36c7e73 100644
--- a/pr.c
+++ b/pr.c
@@ -132,7 +132,7 @@ pr(struct inclist *ip, const char *file, const char *base)
ip->i_flags |= NOTIFIED;
lastfile = NULL;
printf("\n# %s includes:", ip->i_file);
- for (int i = 0; i < ip->i_listlen; i++)
+ for (unsigned int i = 0; i < ip->i_listlen; i++)
printf("\n#\t%s", ip->i_list[i]->i_incstring);
}
@@ -144,6 +144,6 @@ recursive_pr_include(struct inclist *head, const char *file, const char *base)
head->i_flags |= MARKED;
if (head->i_file != file)
pr(head, file, base);
- for (int i = 0; i < head->i_listlen; i++)
+ for (unsigned int i = 0; i < head->i_listlen; i++)
recursive_pr_include(head->i_list[i], file, base);
}