Skip to content

Commit

Permalink
More minor fixes: (#73)
Browse files Browse the repository at this point in the history
* More minor fixes:

- add missing initializers
- fix sign-compare warnings
- fix shadowed variable
  • Loading branch information
zoulasc authored Feb 19, 2020
1 parent ed6ff8c commit c2c8ecb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ int lastfld = 0; /* last used field */
int argno = 1; /* current input argument number */
extern Awkfloat *ARGC;

static Cell dollar0 = { OCELL, CFLD, NULL, EMPTY, 0.0, REC|STR|DONTFREE };
static Cell dollar1 = { OCELL, CFLD, NULL, EMPTY, 0.0, FLD|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, NULL, NULL };

void recinit(unsigned int n)
{
Expand Down Expand Up @@ -461,7 +461,7 @@ void growfldtab(int n) /* make new fields up to at least $n */
if (n > nf)
nf = n;
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);
else /* overflow sizeof int */
xfree(fldtab); /* make it null */
Expand Down
28 changes: 14 additions & 14 deletions run.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ extern Awkfloat srand_seed;
Node *winner = NULL; /* root of parse tree */
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;
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;
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;
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;
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;
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;
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;
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;
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 */

Expand Down Expand Up @@ -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 */
{
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 freed = 0; /* handles potential double freeing when fcn & param share a tempcell */
Node *x;
Expand Down Expand Up @@ -828,10 +828,10 @@ int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like co
static bool have_a_format = false;

if (first) {
char buf[100];
char xbuf[100];

snprintf(buf, sizeof(buf), "%a", 42.0);
have_a_format = (strcmp(buf, "0x1.5p+5") == 0);
snprintf(xbuf, sizeof(xbuf), "%a", 42.0);
have_a_format = (strcmp(xbuf, "0x1.5p+5") == 0);
first = false;
}

Expand Down Expand Up @@ -1869,7 +1869,7 @@ void closeall(void)

static void flush_all(void)
{
int i;
size_t i;

for (i = 0; i < nfiles; i++)
if (files[i].fp)
Expand Down

0 comments on commit c2c8ecb

Please sign in to comment.