[PATCH 2/2] Fix warning -Wchar-subscripts in isspace() and isdigit()

Gedare Bloom gedare at rtems.org
Mon Aug 3 16:19:39 UTC 2020


On Mon, Aug 3, 2020 at 9:11 AM Aschref Ben-Thabet
<aschref.ben-thabet at embedded-brains.de> wrote:
>
> From: Aschref Ben Thabet <aschref.ben-thabet at embedded-brains.de>
>
> The warning may be because you're passing a char to the isspace() macro.
>
> The implementation of isspace() may be via array indexing.
>
> This means that the index for the array can be negative.
>
> This can be a problem as a char could represent a signed value, and you
> may be requesting a negative index.
>
> (The argument to the isspace()/isdegit() macro is defined to be an
> unsigned char the value of which can fit in an unsigned char).
> ---
>  ...subscripts-in-isspace-and-isdigit-.patch.swp | Bin 0 -> 12288 bytes
>  cpukit/libdl/rtl-archive.c                      |   4 ++--
>  2 files changed, 2 insertions(+), 2 deletions(-)
>  create mode 100644 .0001-Fix-warning-Wchar-subscripts-in-isspace-and-isdigit-.patch.swp
>
> diff --git a/.0001-Fix-warning-Wchar-subscripts-in-isspace-and-isdigit-.patch.swp b/.0001-Fix-warning-Wchar-subscripts-in-isspace-and-isdigit-.patch.swp
> new file mode 100644
> index 0000000000000000000000000000000000000000..aea5dc67017f9072d8024cb40115c73be8c1cea5
> GIT binary patch
> literal 12288
> zcmeHNOOG2x5blHs2oRnpBo38C+8xL4 at jSe?<4slxAyFc<64Gu0(z00dXxq(>$JTUv
> zA0)t$GaNY}!3FpUT*#Fh0wm56zkm}La^RcsIJ<EkV&Mepkw5qJbai#rH&rEBuF$!0
> zZI#-#!*IRG*zH%X?vsmmSbvMLKt+R0^txfb_LwUaDc6G_6q=_YPaY}x(LIHAl|}VT
> zi=nDJj^pwxa+mJ}St`>$e>)lk8CR1~MVTCH#bwH+QsW>JJV;~Q$FeUqx5t5w29G?<
> zEEon119J?VV7})Tseby at NqXhw>vQX7Y8WsK7zPXjh5^HXVZbn87%&X{pBd2OBkW^1
> zc(in~S&m2M#&T)~!+>GHFkl!k3>XFs1BL;^fMLKeU>GnA7zX}>3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PlxiH$
> z*Rvp1J(2OtX*7zlvqSAr>izY-vFMN%yShG30+}usdQp<kUthn%+idmP>ScaIWD0I{
> z$VK1#^a!>#3Evly?$E|t7uPRc-6Zs+)6Dh<n$mN!_ZdK2I%Y*%x>aFs1R5r+j?z4A
> zE>8O7Ii5pqqvN|B|14E8bJ&$^H0;pDX@@<%j=WqiI_T+K*(7i8chz4I!%)Prh<TX7
> zC1uBArBFakzvcNo&ucfE$PwW?t<Z_$cD%H7R=936YPzo5XnJvO4XueWxh-;>PVs?R
> Hj?4Z6+n=gx
>
> literal 0
> HcmV?d00001
>

Check your commits before sending them, to make sure only the changes
you want are in them. This binary backup file should not be put in
git-add. You may create your own ignore file(s) for local files to
ignore from all repos, such as *.swp for vim users.

https://git-scm.com/docs/gitignore

> diff --git a/cpukit/libdl/rtl-archive.c b/cpukit/libdl/rtl-archive.c
> index 8f280157ff..e99d9e54a1 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((unsigned char)(s[r + b])))
> +        while (b < ls && isspace ((unsigned char)(s[r + b])))
>          {
>            s[r + b] = '\0';
>            ++b;
>          }
>          b = ls - 1;
> -        while (b > 0 && isspace((unsigned char)(s[r + b])))
> +        while (b > 0 && isspace ((unsigned char)(s[r + b])))
>          {
>            s[r + b] = '\0';
>            --b;
> --
> 2.26.2
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list