Convert (hopefully) all comparisons to NULL
authorlucas <lucas@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 21 Aug 2010 13:52:25 +0000 (13:52 +0000)
committerlucas <lucas@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 21 Aug 2010 13:52:25 +0000 (13:52 +0000)
Apply badzero.cocci, badnull.coci and badnull2.cocci

This should convert all cases where there's a comparison to NULL to simpler
forms. This patch applies the following transformations:

code before patch               ||code after patch
===============================================================

return a == NULL;                 return !a;

return a != NULL;                 return !!a;

func(a == NULL);                  func(!a);

func(a != NULL);                  func(!!a);

b = a == NULL;                    b = !a;

b = a != NULL;                    b = !!a;

b = a == NULL ? c : d;            b = !a ? c : d;

b = a != NULL ? c : d;            b = a ? c : d;

other cases:

a == NULL                         !a
a != NULL                         a

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/embryo@51487 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/embryo_cc_sc1.c
src/bin/embryo_cc_sc2.c
src/bin/embryo_cc_sc3.c
src/bin/embryo_cc_sc4.c
src/bin/embryo_cc_sc6.c
src/bin/embryo_cc_sc7.c
src/bin/embryo_cc_sclist.c

index 2beeb38..7e0b6a2 100644 (file)
@@ -179,14 +179,14 @@ sc_opensrc(char *filename)
 void
 sc_closesrc(void *handle)
 {
-   assert(handle != NULL);
+   assert(!!handle);
    fclose((FILE *) handle);
 }
 
 void
 sc_resetsrc(void *handle, void *position)
 {
-   assert(handle != NULL);
+   assert(!!handle);
    fsetpos((FILE *) handle, (fpos_t *) position);
 }
 
@@ -427,7 +427,7 @@ sc_compile(int argc, char *argv[])
    /* write the binary file (the file is already open) */
    if (errnum == 0 && jmpcode == 0)
      {
-       assert(binf != NULL);
+       assert(!!binf);
        sc_resetasm(outf);      /* flush and loop back, for reading */
        assemble(binf, outf);   /* assembler file is now input */
      }                         /* if */
@@ -442,7 +442,7 @@ sc_compile(int argc, char *argv[])
       free(litq);
    phopt_cleanup();
    stgbuffer_cleanup();
-   assert(jmpcode != 0 || loctab.next == NULL);        /* on normal flow,
+   assert(jmpcode != 0 || !loctab.next);       /* on normal flow,
                                                 * local symbols
                                                 * should already have been deleted */
    delete_symbols(&loctab, 0, TRUE, TRUE);     /* delete local variables
@@ -1784,7 +1784,7 @@ operatorname(char *name)
    char               *str;
    cell                val;
 
-   assert(name != NULL);
+   assert(!!name);
 
    /* check the operator */
    opertok = lex(&val, &str);
@@ -1937,7 +1937,7 @@ operatoradjust(int opertok, symbol * sym, char *opername, int resulttag)
 static int
 check_operatortag(int opertok, int resulttag, char *opername)
 {
-   assert(opername != NULL && opername[0] != '\0');
+   assert(!!opername && opername[0] != '\0');
    switch (opertok)
      {
      case '!':
@@ -2043,7 +2043,7 @@ funcdisplayname(char *dest, char *funcname)
 
    unary = parse_funcname(funcname, &tags[0], &tags[1], opname);
    tagsym[1] = find_constval_byval(&tagname_tab, tags[1]);
-   assert(tagsym[1] != NULL);
+   assert(!!tagsym[1]);
    if (unary)
      {
        sprintf(dest, "operator%s(%s:)", opname, tagsym[1]->name);
@@ -2343,7 +2343,7 @@ newfunc(char *firstname, int firsttag, int fpublic, int fstatic, int stock)
                                         * and labels */
    delete_symbols(&loctab, 0, TRUE, TRUE);     /* clear local variables
                                                 * queue */
-   assert(loctab.next == NULL);
+   assert(!loctab.next);
    curfunc = NULL;
    if (sc_status == statSKIP)
      {
@@ -2587,7 +2587,7 @@ declargs(symbol * sym)
        needtoken(')');
      }                         /* if */
    /* resolve any "sizeof" arguments (now that all arguments are known) */
-   assert(sym->dim.arglist != NULL);
+   assert(!!sym->dim.arglist);
    arglist = sym->dim.arglist;
    for (idx = 0; idx < argcnt && arglist[idx].ident != 0; idx++)
      {
@@ -2845,7 +2845,7 @@ reduce_referrers(symbol * root)
                    {
                       if (ref->parent)
                          continue;     /* hierarchical data type */
-                      assert(ref->refer != NULL);
+                      assert(!!ref->refer);
                       for (i = 0; i < ref->numrefers && ref->refer[i] != sym;
                            i++)
                          /* nothing */ ;
@@ -2948,7 +2948,7 @@ calc_array_datasize(symbol * sym, cell * offset)
 {
    cell                length;
 
-   assert(sym != NULL);
+   assert(!!sym);
    assert(sym->ident == iARRAY || sym->ident == iREFARRAY);
    length = sym->dim.array.length;
    if (sym->dim.array.level > 0)
@@ -3606,7 +3606,7 @@ dofor(void)
     * "continue" must ignore these fields.
     */
    ptr = readwhile();
-   assert(ptr != NULL);
+   assert(!!ptr);
    ptr[wqBRK] = (int)declared;
    ptr[wqCONT] = (int)declared;
    jumplabel(skiplab);         /* skip expression 3 1st time */
@@ -3951,7 +3951,7 @@ doreturn(void)
        needtoken(tTERM);
        rettype |= uRETVALUE;   /* function returns a value */
        /* check tagname with function tagname */
-       assert(curfunc != NULL);
+       assert(!!curfunc);
        if (!matchtag(curfunc->tag, tag, TRUE))
           error(213);          /* tagname mismatch */
      }
@@ -3963,7 +3963,7 @@ doreturn(void)
          {
             char                symname[2 * sNAMEMAX + 16];    /* allow space for user
                                                                 * defined operators */
-            assert(curfunc != NULL);
+            assert(!!curfunc);
             funcdisplayname(symname, curfunc->name);
             error(209, symname);       /* function should return a value */
          }                     /* if */
index 67845f8..3548e43 100644 (file)
@@ -741,7 +741,7 @@ preproc_expr(cell * val, int *tag)
     */
    assert(strlen(pline) < sLINEMAX);
    term = strchr(pline, '\0');
-   assert(term != NULL);
+   assert(!!term);
    chrcat(pline, PREPROC_TERM);        /* the "DEL" code (see SC.H) */
    result = constexpr(val, tag);       /* get value (or 0 on error) */
    *term = '\0';               /* erase the token (if still present) */
@@ -756,7 +756,7 @@ preproc_expr(cell * val, int *tag)
 static char        *
 getstring(char *dest, int max, char *line)
 {
-   assert(dest != NULL && line != NULL);
+   assert(!!dest && !!line);
    *dest = '\0';
    while (*line <= ' ' && *line != '\0')
       line++;                  /* skip whitespace */
@@ -1133,7 +1133,7 @@ command(void)
        if (skiplevel == 0)
          {
             check_empty(lptr);
-            assert(inpf != NULL);
+            assert(!!inpf);
             if (inpf != inpf_org)
                sc_closesrc(inpf);
             inpf = NULL;
@@ -2074,7 +2074,7 @@ lexclr(int clreol)
    if (clreol)
      {
        lptr = strchr(pline, '\0');
-       assert(lptr != NULL);
+       assert(!!lptr);
      }                         /* if */
 }
 
@@ -2370,12 +2370,12 @@ free_symbol(symbol * sym)
    /* free all sub-symbol allocated memory blocks, depending on the
     * kind of the symbol
     */
-   assert(sym != NULL);
+   assert(!!sym);
    if (sym->ident == iFUNCTN)
      {
        /* run through the argument list; "default array" arguments
         * must be freed explicitly; the tag list must also be freed */
-       assert(sym->dim.arglist != NULL);
+       assert(!!sym->dim.arglist);
        for (arg = sym->dim.arglist; arg->ident != 0; arg++)
          {
             if (arg->ident == iREFARRAY && arg->hasdefault)
@@ -2384,12 +2384,12 @@ free_symbol(symbol * sym)
                      && ((arg->hasdefault & uSIZEOF) != 0
                          || (arg->hasdefault & uTAGOF) != 0))
                free(arg->defvalue.size.symname);
-            assert(arg->tags != NULL);
+            assert(!!arg->tags);
             free(arg->tags);
          }                     /* for */
        free(sym->dim.arglist);
      }                         /* if */
-   assert(sym->refer != NULL);
+   assert(!!sym->refer);
    free(sym->refer);
    free(sym);
 }
@@ -2405,7 +2405,7 @@ delete_symbol(symbol * root, symbol * sym)
    while (root->next != sym)
      {
        root = root->next;
-       assert(root != NULL);
+       assert(!!root);
      }                         /* while */
 
    /* unlink it, then free it */
@@ -2518,9 +2518,9 @@ refer_symbol(symbol * entry, symbol * bywhom)
 {
    int                 count;
 
-   assert(bywhom != NULL);     /* it makes no sense to add a "void" referrer */
-   assert(entry != NULL);
-   assert(entry->refer != NULL);
+   assert(!!bywhom);   /* it makes no sense to add a "void" referrer */
+   assert(!!entry);
+   assert(!!entry->refer);
 
    /* see if it is already there */
    for (count = 0; count < entry->numrefers && entry->refer[count] != bywhom;
@@ -2556,7 +2556,7 @@ refer_symbol(symbol * entry, symbol * bywhom)
      }                         /* if */
 
    /* add the referrer */
-   assert(entry->refer[count] == NULL);
+   assert(!entry->refer[count]);
    entry->refer[count] = bywhom;
    return TRUE;
 }
@@ -2612,7 +2612,7 @@ findconst(char *name)
       sym = find_symbol(&glbtab, name, fcurrent);
    if (!sym || sym->ident != iCONSTEXPR)
       return NULL;
-   assert(sym->parent == NULL);        /* constants have no hierarchy */
+   assert(!sym->parent);       /* constants have no hierarchy */
    return sym;
 }
 
@@ -2639,9 +2639,9 @@ addsym(char *name, cell addr, int ident, int vclass, int tag, int usage)
 
    /* global variables/constants/functions may only be defined once */
    assert(!(ident == iFUNCTN || ident == iCONSTEXPR) || vclass != sGLOBAL
-         || findglb(name) == NULL);
+         || !findglb(name));
    /* labels may only be defined once */
-   assert(ident != iLABEL || findloc(name) == NULL);
+   assert(ident != iLABEL || !findloc(name));
 
    /* create an empty referrer list */
    if (!(refer = (symbol **)malloc(sizeof(symbol *))))
@@ -2680,7 +2680,7 @@ addvariable(char *name, cell addr, int ident, int vclass, int tag,
    int                 level;
 
    /* global variables may only be defined once */
-   assert(vclass != sGLOBAL || (sym = findglb(name)) == NULL
+   assert(vclass != sGLOBAL || !(sym = findglb(name))
          || (sym->usage & uDEFINE) == 0);
 
    if (ident == iARRAY || ident == iREFARRAY)
index 69bb34f..2760fc1 100644 (file)
@@ -179,7 +179,7 @@ check_userop(void   (*oper) (void), int tag1, int tag2, int numparam,
      }
    else
      {
-       assert(oper != NULL);
+       assert(!!oper);
        assert(numparam == 1);
        /* try a select group of unary operators */
        assert((sizeof unoperstr / sizeof unoperstr[0]) ==
@@ -248,7 +248,7 @@ check_userop(void   (*oper) (void), int tag1, int tag2, int numparam,
    if (oper == user_inc || oper == user_dec)
      {
        assert(!savepri);
-       assert(lval != NULL);
+       assert(!!lval);
        if (lval->ident == iARRAYCELL || lval->ident == iARRAYCHAR)
           push1();             /* save current address in PRI */
        rvalue(lval);           /* get the symbol's value in PRI */
@@ -269,7 +269,7 @@ check_userop(void   (*oper) (void), int tag1, int tag2, int numparam,
         * result must be stored; this address must be preserved accross the
         * call
         */
-       assert(lval != NULL);   /* this was checked earlier */
+       assert(!!lval); /* this was checked earlier */
        assert(lval->ident == iARRAYCELL || lval->ident == iARRAYCHAR); /* checked earlier */
        push2();
      }                         /* if */
@@ -308,14 +308,14 @@ check_userop(void   (*oper) (void), int tag1, int tag2, int numparam,
    if (sym->x.lib)
       sym->x.lib->value += 1;  /* increment "usage count" of the library */
    sideeffect = TRUE;          /* assume functions carry out a side-effect */
-   assert(resulttag != NULL);
+   assert(!!resulttag);
    *resulttag = sym->tag;      /* save tag of the called function */
 
    if (savepri || savealt)
       pop2();                  /* restore the saved PRI/ALT that into ALT */
    if (oper == user_inc || oper == user_dec)
      {
-       assert(lval != NULL);
+       assert(!!lval);
        if (lval->ident == iARRAYCELL || lval->ident == iARRAYCHAR)
           pop2();              /* restore address (in ALT) */
        store(lval);            /* store PRI in the symbol */
@@ -787,7 +787,7 @@ array_totalsize(symbol * sym)
 {
    cell                length;
 
-   assert(sym != NULL);
+   assert(!!sym);
    assert(sym->ident == iARRAY || sym->ident == iREFARRAY);
    length = sym->dim.array.length;
    if (sym->dim.array.level > 0)
@@ -805,13 +805,13 @@ array_totalsize(symbol * sym)
 static cell
 array_levelsize(symbol * sym, int level)
 {
-   assert(sym != NULL);
+   assert(!!sym);
    assert(sym->ident == iARRAY || sym->ident == iREFARRAY);
    assert(level <= sym->dim.array.level);
    while (level-- > 0)
      {
        sym = finddepend(sym);
-       assert(sym != NULL);
+       assert(!!sym);
      }                         /* if */
    return sym->dim.array.length;
 }
@@ -908,7 +908,7 @@ hier14(value * lval1)
        /* array assignment is permitted too (with restrictions) */
        if (oper)
           return error(23);    /* array assignment must be simple assigment */
-       assert(lval1->sym != NULL);
+       assert(!!lval1->sym);
        if (array_totalsize(lval1->sym) == 0)
           return error(46, lval1->sym->name);  /* unknown array size */
        lvalue = TRUE;
@@ -918,7 +918,7 @@ hier14(value * lval1)
    if (!lvalue)
       return error(22);                /* must be lvalue */
    /* may not change "constant" parameters */
-   assert(lval1->sym != NULL);
+   assert(!!lval1->sym);
    if ((lval1->sym->usage & uCONST) != 0)
       return error(22);                /* assignment to const argument */
    lval3 = *lval1;             /* save symbol to enable storage of expresion result */
@@ -969,7 +969,7 @@ hier14(value * lval1)
             if (lval2.ident == iVARIABLE && lval3.ident == lval2.ident
                 && lval3.sym == lval2.sym)
               {
-                 assert(lval3.sym != NULL);
+                 assert(!!lval3.sym);
                  error(226, lval3.sym->name);  /* self-assignment */
               }                /* if */
          }                     /* if */
@@ -1015,7 +1015,7 @@ hier14(value * lval1)
             symbol             *sym2 = lval2.sym;
             int                 i;
 
-            assert(sym1 != NULL && sym2 != NULL);
+            assert(!!sym1 && !!sym2);
             /* ^^^ sym2 must be valid, because only variables can be
              *     multi-dimensional (there are no multi-dimensional arrays),
              *     sym1 must be valid because it must be an lvalue
@@ -1025,7 +1025,7 @@ hier14(value * lval1)
               {
                  sym1 = finddepend(sym1);
                  sym2 = finddepend(sym2);
-                 assert(sym1 != NULL && sym2 != NULL);
+                 assert(!!sym1 && !!sym2);
                  /* ^^^ both arrays have the same dimensions (this was checked
                   *     earlier) so the dependend should always be found
                   */
@@ -1210,7 +1210,7 @@ hier2(value * lval)
      case tINC:                /* ++lval */
        if (!hier2(lval))
           return error(22);    /* must be lvalue */
-       assert(lval->sym != NULL);
+       assert(!!lval->sym);
        if ((lval->sym->usage & uCONST) != 0)
           return error(22);    /* assignment to const argument */
        if (!check_userop(user_inc, lval->tag, 0, 1, lval, &lval->tag))
@@ -1221,7 +1221,7 @@ hier2(value * lval)
      case tDEC:                /* --lval */
        if (!hier2(lval))
           return error(22);    /* must be lvalue */
-       assert(lval->sym != NULL);
+       assert(!!lval->sym);
        if ((lval->sym->usage & uCONST) != 0)
           return error(22);    /* assignment to const argument */
        if (!check_userop(user_dec, lval->tag, 0, 1, lval, &lval->tag))
@@ -1300,7 +1300,7 @@ hier2(value * lval)
        if (sym && sym->ident != iFUNCTN && sym->ident != iREFFUNC
            && (sym->usage & uDEFINE) == 0)
           sym = NULL;          /* symbol is not a function, it is in the table, but not "defined" */
-       val = (sym != NULL);
+       val = (sym);
        if (!val && find_subst(st, strlen(st)))
           val = 1;
        clear_value(lval);
@@ -1405,7 +1405,7 @@ hier2(value * lval)
               case tINC:       /* lval++ */
                  if (!lvalue)
                     return error(22);  /* must be lvalue */
-                 assert(lval->sym != NULL);
+                 assert(!!lval->sym);
                  if ((lval->sym->usage & uCONST) != 0)
                     return error(22);  /* assignment to const argument */
                  /* on incrementing array cells, the address in PRI must be saved for
@@ -1429,7 +1429,7 @@ hier2(value * lval)
               case tDEC:       /* lval-- */
                  if (!lvalue)
                     return error(22);  /* must be lvalue */
-                 assert(lval->sym != NULL);
+                 assert(!!lval->sym);
                  if ((lval->sym->usage & uCONST) != 0)
                     return error(22);  /* assignment to const argument */
                  saveresult = (lval->ident == iARRAYCELL
@@ -1604,7 +1604,7 @@ hier1(value * lval1)
                     charalign();       /* align character index into array */
               }                /* if */
             /* the indexed item may be another array (multi-dimensional arrays) */
-            assert(lval1->sym == sym && sym != NULL);  /* should still be set */
+            assert(lval1->sym == sym && !!sym);        /* should still be set */
             if (sym->dim.array.level > 0)
               {
                  assert(close == ']'); /* checked earlier */
@@ -1617,7 +1617,7 @@ hier1(value * lval1)
                  /* adjust the "value" structure and find the referenced array */
                  lval1->ident = iREFARRAY;
                  lval1->sym = finddepend(sym);
-                 assert(lval1->sym != NULL);
+                 assert(!!lval1->sym);
                  assert(lval1->sym->dim.array.level ==
                         sym->dim.array.level - 1);
                  /* try to parse subsequent array indices */
@@ -1778,7 +1778,7 @@ primary(value * lval)
          {
             return error(17, st);      /* undefined symbol */
          }                     /* endif */
-       assert(sym != NULL);
+       assert(!!sym);
        assert(sym->ident == iFUNCTN || sym->ident != iREFFUNC);
        lval->sym = sym;
        lval->ident = sym->ident;
@@ -1814,10 +1814,10 @@ setdefarray(cell * string, cell size, cell array_sz, cell * dataaddr,
     * the default array data is "dumped" into the data segment only once (on the
     * first use).
     */
-   assert(string != NULL);
+   assert(!!string);
    assert(size > 0);
    /* check whether to dump the default array */
-   assert(dataaddr != NULL);
+   assert(!!dataaddr);
    if (sc_status == statWRITE && *dataaddr < 0)
      {
        int                 i;
@@ -1907,9 +1907,9 @@ callfunction(symbol * sym)
    cell                lexval;
    char               *lexstr;
 
-   assert(sym != NULL);
+   assert(!!sym);
    arg = sym->dim.arglist;
-   assert(arg != NULL);
+   assert(!!arg);
    stgmark(sSTARTREORDER);
    for (argpos = 0; argpos < sMAXARGS; argpos++)
       arglist[argpos] = ARG_UNHANDLED;
@@ -1974,7 +1974,7 @@ callfunction(symbol * sym)
                       /* always pass by reference */
                       if (lval.ident == iVARIABLE || lval.ident == iREFERENCE)
                         {
-                           assert(lval.sym != NULL);
+                           assert(!!lval.sym);
                            if ((lval.sym->usage & uCONST) != 0
                                && (arg[argidx].usage & uCONST) == 0)
                              {
@@ -2045,7 +2045,7 @@ callfunction(symbol * sym)
                         {
                            if (lvalue)
                              {
-                                assert(lval.sym != NULL);
+                                assert(!!lval.sym);
                                 address(lval.sym);
                              }
                            else
@@ -2121,7 +2121,7 @@ callfunction(symbol * sym)
                            symbol             *sym = lval.sym;
                            short               level = 0;
 
-                           assert(sym != NULL);
+                           assert(!!sym);
                            if (sym->dim.array.level + 1 != arg[argidx].numdim)
                               error(48);       /* array dimensions must match */
                            /* the lengths for all dimensions must match, unless the dimension
@@ -2137,12 +2137,12 @@ callfunction(symbol * sym)
                                 append_constval(&arrayszlst, arg[argidx].name,
                                                 sym->dim.array.length, level);
                                 sym = finddepend(sym);
-                                assert(sym != NULL);
+                                assert(!!sym);
                                 level++;
                              } /* if */
                            /* the last dimension is checked too, again, unless it is zero */
                            assert(level < sDIMEN_MAX);
-                           assert(sym != NULL);
+                           assert(!!sym);
                            if (arg[argidx].dim[level] != 0
                                && sym->dim.array.length !=
                                arg[argidx].dim[level])
index 57cbca1..85c9795 100644 (file)
@@ -336,7 +336,7 @@ rvalue(value * lval)
    else if (lval->ident == iREFERENCE)
      {
        /* indirect fetch, but address not yet in PRI */
-       assert(sym != NULL);
+       assert(!!sym);
        assert(sym->vclass == sLOCAL);  /* global references don't exist in Small */
        if (sym->vclass == sLOCAL)
           stgwrite("\tlref.s.pri ");
@@ -349,7 +349,7 @@ rvalue(value * lval)
    else
      {
        /* direct or stack relative fetch */
-       assert(sym != NULL);
+       assert(!!sym);
        if (sym->vclass == sLOCAL)
           stgwrite("\tload.s.pri ");
        else
@@ -367,7 +367,7 @@ rvalue(value * lval)
 void
 address(symbol * sym)
 {
-   assert(sym != NULL);
+   assert(!!sym);
    /* the symbol can be a local array, a global array, or an array
     * that is passed by reference.
     */
@@ -416,7 +416,7 @@ store(value * lval)
      }
    else if (lval->ident == iREFERENCE)
      {
-       assert(sym != NULL);
+       assert(!!sym);
        if (sym->vclass == sLOCAL)
           stgwrite("\tsref.s.pri ");
        else
@@ -426,7 +426,7 @@ store(value * lval)
      }
    else
      {
-       assert(sym != NULL);
+       assert(!!sym);
        markusage(sym, uWRITTEN);
        if (sym->vclass == sLOCAL)
           stgwrite("\tstor.s.pri ");
@@ -455,7 +455,7 @@ memcopy(cell size)
 void
 copyarray(symbol * sym, cell size)
 {
-   assert(sym != NULL);
+   assert(!!sym);
    /* the symbol can be a local array, a global array, or an array
     * that is passed by reference.
     */
@@ -485,7 +485,7 @@ fillarray(symbol * sym, cell size, cell val)
 {
    const1(val);                /* load val in PRI */
 
-   assert(sym != NULL);
+   assert(!!sym);
    /* the symbol can be a local array, a global array, or an array
     * that is passed by reference.
     */
@@ -658,7 +658,7 @@ ffcase(cell val, char *labelname, int newtable)
 void
 ffcall(symbol * sym, int numargs)
 {
-   assert(sym != NULL);
+   assert(!!sym);
    assert(sym->ident == iFUNCTN);
    if ((sym->usage & uNATIVE) != 0)
      {
@@ -1177,7 +1177,7 @@ inc(value * lval)
      }
    else if (lval->ident == iREFERENCE)
      {
-       assert(sym != NULL);
+       assert(!!sym);
        stgwrite("\tpush.pri\n");
        /* load dereferenced value */
        assert(sym->vclass == sLOCAL);  /* global references don't exist in Small */
@@ -1200,7 +1200,7 @@ inc(value * lval)
    else
      {
        /* local or global variable */
-       assert(sym != NULL);
+       assert(!!sym);
        if (sym->vclass == sLOCAL)
           stgwrite("\tinc.s ");
        else
@@ -1243,7 +1243,7 @@ dec(value * lval)
      }
    else if (lval->ident == iREFERENCE)
      {
-       assert(sym != NULL);
+       assert(!!sym);
        stgwrite("\tpush.pri\n");
        /* load dereferenced value */
        assert(sym->vclass == sLOCAL);  /* global references don't exist in Small */
@@ -1266,7 +1266,7 @@ dec(value * lval)
    else
      {
        /* local or global variable */
-       assert(sym != NULL);
+       assert(!!sym);
        if (sym->vclass == sLOCAL)
           stgwrite("\tdec.s ");
        else
index 61e1828..2fe23d9 100644 (file)
@@ -156,7 +156,7 @@ static void
 write_encoded(FILE * fbin, ucell * c, int num)
 {
    assert(sizeof(cell) <= 4);  /* code must be adjusted for larger cells */
-   assert(fbin != NULL);
+   assert(!!fbin);
    while (num-- > 0)
      {
        if (sc_compress)
@@ -298,7 +298,7 @@ do_call(FILE * fbin, char *params, cell opcode)
     * already have been set (in order for static globals to be found).
     */
    sym = findglb(name);
-   assert(sym != NULL);
+   assert(!!sym);
    assert(sym->ident == iFUNCTN || sym->ident == iREFFUNC);
    assert(sym->vclass == sGLOBAL);
 
@@ -322,7 +322,7 @@ do_jump(FILE * fbin, char *params, cell opcode)
 
    if (fbin)
      {
-       assert(lbltab != NULL);
+       assert(!!lbltab);
        p = lbltab[i];
        write_encoded(fbin, (ucell *) & opcode, 1);
        write_encoded(fbin, &p, 1);
@@ -414,7 +414,7 @@ do_switch(FILE * fbin, char *params, cell opcode)
 
    if (fbin)
      {
-       assert(lbltab != NULL);
+       assert(!!lbltab);
        p = lbltab[i];
        write_encoded(fbin, (ucell *) & opcode, 1);
        write_encoded(fbin, &p, 1);
@@ -438,7 +438,7 @@ do_case(FILE * fbin, char *params, cell opcode __UNUSED__)
 
    if (fbin)
      {
-       assert(lbltab != NULL);
+       assert(!!lbltab);
        p = lbltab[i];
        write_encoded(fbin, &v, 1);
        write_encoded(fbin, &p, 1);
@@ -625,7 +625,7 @@ findopcode(char *instr, int maxlen)
    while (low < high)
      {
        mid = (low + high) / 2;
-       assert(opcodelist[mid].name != NULL);
+       assert(!!opcodelist[mid].name);
        cmp = strcasecmp(str, opcodelist[mid].name);
        if (cmp > 0)
           low = mid + 1;
@@ -664,10 +664,10 @@ assemble(FILE * fout, FILE * fin)
    /* verify that the opcode list is sorted (skip entry 1; it is reserved
     * for a non-existant opcode)
     */
-   assert(opcodelist[1].name != NULL);
+   assert(!!opcodelist[1].name);
    for (i = 2; i < (sizeof opcodelist / sizeof opcodelist[0]); i++)
      {
-       assert(opcodelist[i].name != NULL);
+       assert(!!opcodelist[i].name);
        assert(strcasecmp(opcodelist[i].name, opcodelist[i - 1].name) > 0);
      }                         /* for */
 #endif
@@ -867,7 +867,7 @@ assemble(FILE * fout, FILE * fin)
             char                alias[sNAMEMAX + 1];
 
             sym = nativelist[i];
-            assert(sym != NULL);
+            assert(!!sym);
             if (!lookup_alias(alias, sym->name))
               {
                  assert(strlen(sym->name) <= sNAMEMAX);
@@ -1044,7 +1044,7 @@ assemble(FILE * fout, FILE * fin)
                /* nothing */ ;
             assert(params > instr);
             i = findopcode(instr, (int)(params - instr));
-            assert(opcodelist[i].name != NULL);
+            assert(!!opcodelist[i].name);
             if (opcodelist[i].segment == pass)
                opcodelist[i].func(fout, skipwhitespace(params),
                                   opcodelist[i].opcode);
index c8a977e..bdc2b8e 100644 (file)
@@ -533,7 +533,7 @@ replacesequence(char *pattern, char symbols[_maxoptvars][_aliasmax + 1],
     * that the same symbol may occur multiple times in the pattern) plus
     * line endings and startings ('\t' to start a line and '\n\0' to end one)
     */
-   assert(repl_length != NULL);
+   assert(!!repl_length);
    *repl_length = 0;
    lptr = pattern;
    while (*lptr)
@@ -627,7 +627,7 @@ stgopt(char *start, char *end)
    char                symbols[_maxoptvars][_aliasmax + 1];
    int                 seq, match_length, repl_length;
 
-   assert(sequences != NULL);
+   assert(!!sequences);
    while (start < end)
      {
        if ((sc_debug & sNOOPTIMIZE) != 0 || sc_status != statWRITE)
@@ -677,7 +677,7 @@ stgopt(char *start, char *end)
                       seq++;
                    }           /* if */
               }                /* while */
-            assert(sequences[seq].find == NULL);
+            assert(!sequences[seq].find);
             filewrite(start);
          }                     /* if */
        assert(start < end);
index 099c6b2..dcba357 100644 (file)
@@ -39,9 +39,9 @@ insert_stringpair(stringpair * root, char *first, char *second, int matchlength)
 {
    stringpair         *cur, *pred;
 
-   assert(root != NULL);
-   assert(first != NULL);
-   assert(second != NULL);
+   assert(!!root);
+   assert(!!first);
+   assert(!!second);
    /* create a new node, and check whether all is okay */
    if (!(cur = (stringpair *)malloc(sizeof(stringpair))))
       return NULL;
@@ -71,13 +71,13 @@ delete_stringpairtable(stringpair * root)
 {
    stringpair         *cur, *next;
 
-   assert(root != NULL);
+   assert(!!root);
    cur = root->next;
    while (cur)
      {
        next = cur->next;
-       assert(cur->first != NULL);
-       assert(cur->second != NULL);
+       assert(!!cur->first);
+       assert(!!cur->second);
        free(cur->first);
        free(cur->second);
        free(cur);
@@ -92,7 +92,7 @@ find_stringpair(stringpair * cur, char *first, int matchlength)
    int                 result = 0;
 
    assert(matchlength > 0);    /* the function cannot handle zero-length comparison */
-   assert(first != NULL);
+   assert(!!first);
    while (cur && result <= 0)
      {
        result = (int)*cur->first - (int)*first;
@@ -112,15 +112,15 @@ delete_stringpair(stringpair * root, stringpair * item)
 {
    stringpair         *cur;
 
-   assert(root != NULL);
+   assert(!!root);
    cur = root;
    while (cur->next)
      {
        if (cur->next == item)
          {
             cur->next = item->next;    /* unlink from list */
-            assert(item->first != NULL);
-            assert(item->second != NULL);
+            assert(!!item->first);
+            assert(!!item->second);
             free(item->first);
             free(item->second);
             free(item);
@@ -139,9 +139,9 @@ insert_alias(char *name, char *alias)
 {
    stringpair         *cur;
 
-   assert(name != NULL);
+   assert(!!name);
    assert(strlen(name) <= sNAMEMAX);
-   assert(alias != NULL);
+   assert(!!alias);
    assert(strlen(alias) <= sEXPMAX);
    if (!(cur = insert_stringpair(&alias_tab, name, alias, strlen(name))))
       error(103);              /* insufficient memory (fatal error) */
@@ -158,7 +158,7 @@ lookup_alias(char *target, char *name)
        assert(strlen(cur->second) <= sEXPMAX);
        strcpy(target, cur->second);
      }                         /* if */
-   return cur != NULL;
+   return !!cur;
 }
 
 void
@@ -175,7 +175,7 @@ insert_path(char *path)
 {
    stringlist         *cur;
 
-   assert(path != NULL);
+   assert(!!path);
    if (!(cur = (stringlist *)malloc(sizeof(stringlist))))
       error(103);              /* insufficient memory (fatal error) */
    if (!(cur->line = strdup(path)))
@@ -194,7 +194,7 @@ get_path(int index)
       cur = cur->next;
    if (cur)
      {
-       assert(cur->line != NULL);
+       assert(!!cur->line);
        return cur->line;
      }                         /* if */
    return NULL;
@@ -208,7 +208,7 @@ delete_pathtable(void)
    while (cur)
      {
        next = cur->next;
-       assert(cur->line != NULL);
+       assert(!!cur->line);
        free(cur->line);
        free(cur);
        cur = next;
@@ -240,8 +240,8 @@ insert_subst(char *pattern, char *substitution, int prefixlen)
 {
    stringpair         *cur;
 
-   assert(pattern != NULL);
-   assert(substitution != NULL);
+   assert(!!pattern);
+   assert(!!substitution);
    if (!(cur = insert_stringpair(&substpair, pattern, substitution, prefixlen)))
       error(103);              /* insufficient memory (fatal error) */
    adjustindex(*pattern);
@@ -253,7 +253,7 @@ find_subst(char *name, int length)
 {
    stringpair         *item;
 
-   assert(name != NULL);
+   assert(!!name);
    assert(length > 0);
    assert((*name >= 'A' && *name <= 'Z') || (*name >= 'a' && *name <= 'z')
          || *name == '_');
@@ -268,7 +268,7 @@ delete_subst(char *name, int length)
 {
    stringpair         *item;
 
-   assert(name != NULL);
+   assert(!!name);
    assert(length > 0);
    assert((*name >= 'A' && *name <= 'Z') || (*name >= 'a' && *name <= 'z')
          || *name == '_');