[PATCH] The warning may be because you're passing a char to the isspace() macro. The implementation of isspace() may be via array indexing. (The argument to the isspace()/isdegit() macro is defined to be an unsigned char the value of which can fit in an unsignedchar).

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Jul 20 14:22:43 UTC 2020


Hello Aschref,

please fix the format of the commit message to be in line with standard 
line length limits for the subject and the text body:

https://chris.beams.io/posts/git-commit/

On 20/07/2020 15:53, Aschref Ben-Thabet wrote:
> From: Aschref Ben Thabet <aschref.ben-thabet at embedded-brains.de>
>
> at ctype.h in GNU libc, and while there's a complicated mess of macros and functions, somewhere in the definition of isspace() there's an array being indexed.
>
> See if isspace((unsigned char) *str) gets rid of the warning.
>
> The line array[c] is very likely a bug, because the type char can be signed or unsigned—it's up to the compiler. If char is signed, then it's possible for c to be negative, in which case accessing a negative array index leads to Undefined Behavior.
> ---
>   cpukit/libdl/rtl-archive.c              | 4 ++--
>   testsuites/fstests/fsdosfsname01/init.c | 2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/cpukit/libdl/rtl-archive.c b/cpukit/libdl/rtl-archive.c
> index eb7641b034..8f280157ff 100644
> --- a/cpukit/libdl/rtl-archive.c
> +++ b/cpukit/libdl/rtl-archive.c
> @@ -516,13 +516,13 @@ rtems_rtl_archives_load_config (rtems_rtl_archives* archives)
>         {
>           size_t ls = strlen (&s[r]);
>           size_t b = 0;
> -        while (b < ls && isspace (s[r + b]))
> +        while (b < ls && isspace((unsigned char)(s[r + b])))

This change is not in line with the coding style of this file. Please 
change it to:

isspace ((unsigned char) s[r + b])

Try to avoid superfluous parenthesis.

>           {
>             s[r + b] = '\0';
>             ++b;
>           }
>           b = ls - 1;
> -        while (b > 0 && isspace (s[r + b]))
> +        while (b > 0 && isspace((unsigned char)(s[r + b])))
Likewise.
>           {
>             s[r + b] = '\0';
>             --b;
> diff --git a/testsuites/fstests/fsdosfsname01/init.c b/testsuites/fstests/fsdosfsname01/init.c
> index 3689da8eed..8eb7982e22 100644
> --- a/testsuites/fstests/fsdosfsname01/init.c
> +++ b/testsuites/fstests/fsdosfsname01/init.c
> @@ -429,7 +429,7 @@ static void test_creating_invalid_directories( void )
>                 sizeof( dirname ),
>                 "%s/%s",
>                 MOUNT_DIR,
> -              DIRECTORY_NAMES_INVALID[index] );
> +               DIRECTORY_NAMES_INVALID[index]);
This is an unrelated change. Please remove it from the commit.
>       rc = mkdir( dirname, S_IRWXU | S_IRWXG | S_IRWXO );
>       rtems_test_assert( rc == -1 );
>     }

Please send a v2 of the patch to the mailing list using

git format-patch -v2 ...



More information about the devel mailing list