More minor fixes: (#73)

* More minor fixes:

- add missing initializers
- fix sign-compare warnings
- fix shadowed variable
This commit is contained in:
zoulasc 2020-02-19 13:44:49 -05:00 committed by GitHub
parent ed6ff8c1cb
commit c2c8ecbedf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 17 deletions

6
lib.c
View File

@ -55,8 +55,8 @@ int lastfld = 0; /* last used field */
int argno = 1; /* current input argument number */ int argno = 1; /* current input argument number */
extern Awkfloat *ARGC; extern Awkfloat *ARGC;
static Cell dollar0 = { OCELL, CFLD, NULL, EMPTY, 0.0, REC|STR|DONTFREE }; static Cell dollar0 = { OCELL, CFLD, NULL, EMPTY, 0.0, REC|STR|DONTFREE, NULL, NULL };
static Cell dollar1 = { OCELL, CFLD, NULL, EMPTY, 0.0, FLD|STR|DONTFREE }; static Cell dollar1 = { OCELL, CFLD, NULL, EMPTY, 0.0, FLD|STR|DONTFREE, NULL, NULL };
void recinit(unsigned int n) void recinit(unsigned int n)
{ {
@ -461,7 +461,7 @@ void growfldtab(int n) /* make new fields up to at least $n */
if (n > nf) if (n > nf)
nf = n; nf = n;
s = (nf+1) * (sizeof (struct Cell *)); /* freebsd: how much do we need? */ s = (nf+1) * (sizeof (struct Cell *)); /* freebsd: how much do we need? */
if (s / sizeof(struct Cell *) - 1 == nf) /* didn't overflow */ if (s / sizeof(struct Cell *) - 1 == (size_t)nf) /* didn't overflow */
fldtab = realloc(fldtab, s); fldtab = realloc(fldtab, s);
else /* overflow sizeof int */ else /* overflow sizeof int */
xfree(fldtab); /* make it null */ xfree(fldtab); /* make it null */

28
run.c
View File

@ -77,23 +77,23 @@ extern Awkfloat srand_seed;
Node *winner = NULL; /* root of parse tree */ Node *winner = NULL; /* root of parse tree */
Cell *tmps; /* free temporary cells for execution */ Cell *tmps; /* free temporary cells for execution */
static Cell truecell ={ OBOOL, BTRUE, 0, 0, 1.0, NUM, NULL }; static Cell truecell ={ OBOOL, BTRUE, 0, 0, 1.0, NUM, NULL, NULL };
Cell *True = &truecell; Cell *True = &truecell;
static Cell falsecell ={ OBOOL, BFALSE, 0, 0, 0.0, NUM, NULL }; static Cell falsecell ={ OBOOL, BFALSE, 0, 0, 0.0, NUM, NULL, NULL };
Cell *False = &falsecell; Cell *False = &falsecell;
static Cell breakcell ={ OJUMP, JBREAK, 0, 0, 0.0, NUM, NULL }; static Cell breakcell ={ OJUMP, JBREAK, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jbreak = &breakcell; Cell *jbreak = &breakcell;
static Cell contcell ={ OJUMP, JCONT, 0, 0, 0.0, NUM, NULL }; static Cell contcell ={ OJUMP, JCONT, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jcont = &contcell; Cell *jcont = &contcell;
static Cell nextcell ={ OJUMP, JNEXT, 0, 0, 0.0, NUM, NULL }; static Cell nextcell ={ OJUMP, JNEXT, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jnext = &nextcell; Cell *jnext = &nextcell;
static Cell nextfilecell ={ OJUMP, JNEXTFILE, 0, 0, 0.0, NUM, NULL }; static Cell nextfilecell ={ OJUMP, JNEXTFILE, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jnextfile = &nextfilecell; Cell *jnextfile = &nextfilecell;
static Cell exitcell ={ OJUMP, JEXIT, 0, 0, 0.0, NUM, NULL }; static Cell exitcell ={ OJUMP, JEXIT, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jexit = &exitcell; Cell *jexit = &exitcell;
static Cell retcell ={ OJUMP, JRET, 0, 0, 0.0, NUM, NULL }; static Cell retcell ={ OJUMP, JRET, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jret = &retcell; Cell *jret = &retcell;
static Cell tempcell ={ OCELL, CTEMP, 0, EMPTY, 0.0, NUM|STR|DONTFREE, NULL }; static Cell tempcell ={ OCELL, CTEMP, 0, EMPTY, 0.0, NUM|STR|DONTFREE, NULL, NULL };
Node *curnode = NULL; /* the node being executed, for debugging */ Node *curnode = NULL; /* the node being executed, for debugging */
@ -226,7 +226,7 @@ struct Frame *frp = NULL; /* frame pointer. bottom level unused */
Cell *call(Node **a, int n) /* function call. very kludgy and fragile */ Cell *call(Node **a, int n) /* function call. very kludgy and fragile */
{ {
static const Cell newcopycell = { OCELL, CCOPY, 0, EMPTY, 0.0, NUM|STR|DONTFREE, NULL }; static const Cell newcopycell = { OCELL, CCOPY, 0, EMPTY, 0.0, NUM|STR|DONTFREE, NULL, NULL };
int i, ncall, ndef; int i, ncall, ndef;
int freed = 0; /* handles potential double freeing when fcn & param share a tempcell */ int freed = 0; /* handles potential double freeing when fcn & param share a tempcell */
Node *x; Node *x;
@ -828,10 +828,10 @@ int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like co
static bool have_a_format = false; static bool have_a_format = false;
if (first) { if (first) {
char buf[100]; char xbuf[100];
snprintf(buf, sizeof(buf), "%a", 42.0); snprintf(xbuf, sizeof(xbuf), "%a", 42.0);
have_a_format = (strcmp(buf, "0x1.5p+5") == 0); have_a_format = (strcmp(xbuf, "0x1.5p+5") == 0);
first = false; first = false;
} }
@ -1869,7 +1869,7 @@ void closeall(void)
static void flush_all(void) static void flush_all(void)
{ {
int i; size_t i;
for (i = 0; i < nfiles; i++) for (i = 0; i < nfiles; i++)
if (files[i].fp) if (files[i].fp)