git: 80f314327434 - main - yacc: Use NULL instead of 0 for pointers

Jung-uk Kim jkim at FreeBSD.org
Thu Feb 11 23:53:37 UTC 2021


The branch main has been updated by jkim:

URL: https://cgit.FreeBSD.org/src/commit/?id=80f31432743446a1e8e4f8cb8268b74ac4e4f2da

commit 80f31432743446a1e8e4f8cb8268b74ac4e4f2da
Author:     Jung-uk Kim <jkim at FreeBSD.org>
AuthorDate: 2021-02-11 23:40:00 +0000
Commit:     Jung-uk Kim <jkim at FreeBSD.org>
CommitDate: 2021-02-11 23:40:00 +0000

    yacc: Use NULL instead of 0 for pointers
    
    Note araujo tried to fix it in r298241 but he only touched generated
    files for bootstrap.  This commit properly fixes the problem.
---
 contrib/byacc/btyaccpar.c    | 8 ++++----
 contrib/byacc/btyaccpar.skel | 8 ++++----
 contrib/byacc/yaccpar.c      | 6 +++---
 contrib/byacc/yaccpar.skel   | 6 +++---
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/contrib/byacc/btyaccpar.c b/contrib/byacc/btyaccpar.c
index 64a9febd17e4..f4db838e3244 100644
--- a/contrib/byacc/btyaccpar.c
+++ b/contrib/byacc/btyaccpar.c
@@ -326,14 +326,14 @@ const char *const body_1[] =
     "",
     "    i = (int) (data->s_mark - data->s_base);",
     "    newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));",
-    "    if (newss == 0)",
+    "    if (newss == NULL)",
     "        return YYENOMEM;",
     "",
     "    data->s_base = newss;",
     "    data->s_mark = newss + i;",
     "",
     "    newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));",
-    "    if (newvs == 0)",
+    "    if (newvs == NULL)",
     "        return YYENOMEM;",
     "",
     "    data->l_base = newvs;",
@@ -341,7 +341,7 @@ const char *const body_1[] =
     "",
     "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
     "    newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));",
-    "    if (newps == 0)",
+    "    if (newps == NULL)",
     "        return YYENOMEM;",
     "",
     "    data->p_base = newps;",
@@ -446,7 +446,7 @@ const char *const body_2[] =
     "#if YYDEBUG",
     "    const char *yys;",
     "",
-    "    if ((yys = getenv(\"YYDEBUG\")) != 0)",
+    "    if ((yys = getenv(\"YYDEBUG\")) != NULL)",
     "    {",
     "        yyn = *yys;",
     "        if (yyn >= '0' && yyn <= '9')",
diff --git a/contrib/byacc/btyaccpar.skel b/contrib/byacc/btyaccpar.skel
index 009942ee041f..84ea14846138 100644
--- a/contrib/byacc/btyaccpar.skel
+++ b/contrib/byacc/btyaccpar.skel
@@ -271,14 +271,14 @@ static int yygrowstack(YYSTACKDATA *data)
 
     i = (int) (data->s_mark - data->s_base);
     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
-    if (newss == 0)
+    if (newss == NULL)
         return YYENOMEM;
 
     data->s_base = newss;
     data->s_mark = newss + i;
 
     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
-    if (newvs == 0)
+    if (newvs == NULL)
         return YYENOMEM;
 
     data->l_base = newvs;
@@ -286,7 +286,7 @@ static int yygrowstack(YYSTACKDATA *data)
 
 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
     newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
-    if (newps == 0)
+    if (newps == NULL)
         return YYENOMEM;
 
     data->p_base = newps;
@@ -381,7 +381,7 @@ YYPARSE_DECL()
 #if YYDEBUG
     const char *yys;
 
-    if ((yys = getenv("YYDEBUG")) != 0)
+    if ((yys = getenv("YYDEBUG")) != NULL)
     {
         yyn = *yys;
         if (yyn >= '0' && yyn <= '9')
diff --git a/contrib/byacc/yaccpar.c b/contrib/byacc/yaccpar.c
index e57bd4bb7d36..30299074523f 100644
--- a/contrib/byacc/yaccpar.c
+++ b/contrib/byacc/yaccpar.c
@@ -160,14 +160,14 @@ const char *const body_1[] =
     "",
     "    i = (int) (data->s_mark - data->s_base);",
     "    newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));",
-    "    if (newss == 0)",
+    "    if (newss == NULL)",
     "        return YYENOMEM;",
     "",
     "    data->s_base = newss;",
     "    data->s_mark = newss + i;",
     "",
     "    newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));",
-    "    if (newvs == 0)",
+    "    if (newvs == NULL)",
     "        return YYENOMEM;",
     "",
     "    data->l_base = newvs;",
@@ -206,7 +206,7 @@ const char *const body_2[] =
     "#if YYDEBUG",
     "    const char *yys;",
     "",
-    "    if ((yys = getenv(\"YYDEBUG\")) != 0)",
+    "    if ((yys = getenv(\"YYDEBUG\")) != NULL)",
     "    {",
     "        yyn = *yys;",
     "        if (yyn >= '0' && yyn <= '9')",
diff --git a/contrib/byacc/yaccpar.skel b/contrib/byacc/yaccpar.skel
index 32e2d1560537..f12e0d29cca9 100644
--- a/contrib/byacc/yaccpar.skel
+++ b/contrib/byacc/yaccpar.skel
@@ -119,14 +119,14 @@ static int yygrowstack(YYSTACKDATA *data)
 
     i = (int) (data->s_mark - data->s_base);
     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
-    if (newss == 0)
+    if (newss == NULL)
         return YYENOMEM;
 
     data->s_base = newss;
     data->s_mark = newss + i;
 
     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
-    if (newvs == 0)
+    if (newvs == NULL)
         return YYENOMEM;
 
     data->l_base = newvs;
@@ -161,7 +161,7 @@ YYPARSE_DECL()
 #if YYDEBUG
     const char *yys;
 
-    if ((yys = getenv("YYDEBUG")) != 0)
+    if ((yys = getenv("YYDEBUG")) != NULL)
     {
         yyn = *yys;
         if (yyn >= '0' && yyn <= '9')


More information about the dev-commits-src-all mailing list