[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] warnings: address -Wnull-dereference in reader.c
From: |
Akim Demaille |
Subject: |
Re: [PATCH] warnings: address -Wnull-dereference in reader.c |
Date: |
Wed, 15 Aug 2018 14:39:37 +0200 |
> Le 5 août 2018 à 16:40, Akim Demaille <address@hidden> a écrit :
>
>> Le 8 juil. 2018 à 20:08, David Michael <address@hidden> a écrit :
>>
>> This corrects a build failure when using GCC8 and configured with
>> the --enable-gcc-warnings and --enable-assert options:
>
> hi David, thanks!
>
> I will install this slightly different version of your patch:
And on top of that patch, I installed the following.
To fix a stupid mistake (will C stop requiring
void some day?), and to avoid the warning even with
NDEBUG set.
commit 93057cb7479db3196f77d71482951deb3ab5a06c
Author: Akim Demaille <address@hidden>
Date: Wed Aug 15 13:51:36 2018 +0200
fix incorrect C code
Commit 3df32101e7978eaafa63bce8908de3dcae4d9cda introduced invalid C
code. Caught by GCC 7.3.0.
* bootstrap.conf (gnulib_modules): We need assume.
* src/reader.c (find_start_symbol): Fix the signature (too much C++,
sorry...).
Prefer 'assume' to 'assert', so that we don't have these warnings even
when NDEBUG is defined.
diff --git a/bootstrap.conf b/bootstrap.conf
index d8c7d128..b2d0f974 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -17,7 +17,8 @@
# gnulib modules used by this package.
gnulib_modules='
- argmatch assert calloc-posix close closeout config-h c-strcase
+ argmatch assert assume
+ calloc-posix close closeout config-h c-strcase
configmake
dirname
error extensions fdl fopen-safer
diff --git a/src/reader.c b/src/reader.c
index 18a3fc2d..12faef96 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -726,20 +726,20 @@ prepare_percent_define_front_end_variables (void)
/* Find the first LHS which is not a dummy. */
static symbol *
-find_start_symbol ()
+find_start_symbol (void)
{
symbol_list *res = grammar;
for (;
- res != NULL && symbol_is_dummy (res->content.sym);
+ res && symbol_is_dummy (res->content.sym);
res = res->next)
{
for (res = res->next;
- res != NULL && res->content.sym != NULL;
+ res && res->content.sym;
res = res->next)
continue;
- aver (res != NULL);
+ assume (res);
}
- aver (res != NULL);
+ assume (res);
return res->content.sym;
}