Posix Tests Compiler Warnings v2

Rempel, Cynthia cynt6007 at vandals.uidaho.edu
Thu Aug 22 06:11:02 UTC 2013


Hi,

This patch fixes ~32 compiler warnings for the sparc-sis bsp, by making the posix test cases more posix compliant.
This also deprecates PRIxpthread_t, PRIxblksize_t, and PRIxblkcnt_t...
which are helper macros for testing RTEMS... and don't add to posix compliance...

Most of this patch could have been done with the clever use of sed...

>________________________________________
>From: Joel Sherrill [joel.sherrill at oarcorp.com]
>Sent: Wednesday, August 21, 2013 9:45 AM
>To: Gedare Bloom
>Cc: Rempel, Cynthia; rtems-devel at rtems.org
>Subject: Re: Posix Tests Compiler Warnings
>
>On 8/21/2013 7:59 AM, Gedare Bloom wrote:
>
>Hi,
>
>>The documentation you pointed to is the Linux kernel doc, which are
>>not entirely relevant for RTEMS. Is there a POSIX standard that
>>governs this issue?
>Well... the basic types are covered by inttypes.h which is POSIX and
>the link I posted covers.  That file is in newlib.
>http://pubs.opengroup.org/onlinepubs/009604599/basedefs/inttypes.h.html
>inttypes.h itself is (more than likely) correct.
>
>As an aside, inttypes.h prototypes four methods. newlib does not
>have implementations of them.  I started a discussion on adding them
>and this is the thread:
>
>http://sourceware.org/ml/newlib/2013/msg00626.html
>
>Corinna Vinschen proposed a rather elegant solution which would provide
>them as aliases for existing routines. Then the documentation for each
>would have to be added.
Where would the documentation be done?
>
>If you are working in this area, this is a good thing to touch on.
Interesting...
can someone do inline routines in newlib?...
that might meet the anti-macro requirement...

>>This looks like mostly converting pointer types to long unsigned int?
>>Some of the changes seem like they should not be necessary, like:
>>-    printf(  "...st_blksize %" PRIxblksize_t "\n", statbuf.st_blksize );
>>-    printf(  "...st_blocks  %" PRIxblkcnt_t "\n", statbuf.st_blocks );
>>+    printf(  "...st_blksize %" PRIxblksize_t "\n", (long unsigned int)statbuf.st_blksize );
>>+    printf(  "...st_blocks  %" PRIxblkcnt_t "\n", (long unsigned int)statbuf.st_blocks );
Sadly, they are necessary... see: http://pubs.opengroup.org/onlinepubs/009604599/basedefs/inttypes.h.html

>These are NOT covered by the POSIX inttypes.h. I see one of them
>defined in ./testsuites/psxtests/include/pmacros.h. So they are
>test support and logically extend the type specific print specifiers
>in inttypes.h.  Apparently some of them are wrong.
in my humble opinion, it would be easier in the long run to change the tests, and deprecate the non-compliant macros, in favor of posix compliant macros (which has been done in this patch), than to get the non-compliant macros to work...

>If you eliminate the warning on sparc or powerpc, then that will
>likely cover most targets. But if the underlying type varies based
>on target architecture, then you will have to check it on the
>varying architectures.
This eliminates them on sparc... haven't tried ppc...

>Should be a series of one-line fixes which don't reflect the mental
>power required to solve. :)
Yes, the big patch didn't really require much in-depth thought, just a lot of back-and-forth looking at references...

>>Here the printf already should accommodate the size of the type of the
>>blksize_t and blkcnt_t. This is how I usually see this issue of
>>variably-sized types being printed. I don't know the right answer.
I'd suggest considering deprecating the non-compliant macros that are challenging to maintain, and use variable sized print specifiers (i.e. PRIxMAX/uintmax_t) provided by posix (if really needed)...
more thought probably should be put into substitutions outside of printf statements in tests, though (as outside of printf statements for testing size, and speed resources are limited)... 

>>-Gedare

On Wed, Aug 21, 2013 at 12:33 AM, Rempel, Cynthia
<cynt6007 at vandals.uidaho.edu><mailto:cynt6007 at vandals.uidaho.edu> wrote:


Hi,

Reducing the number of unnecessary compiler warnings makes it easier to find (and fix) real compiler warnings...

The fix is in accordance with:

https://www.kernel.org/doc/Documentation/printk-formats.txt
If <type> is dependent on a config option for its size (e.g., sector_t,
blkcnt_t) or is architecture-dependent for its size (e.g., tcflag_t), use a
format specifier of its largest possible type and explicitly cast to it.

This patch reduces the number of posix tests compiler warnings, by recasting arguments in printf statements...

Thanks,
Cynthia Rempel
_______________________________________________
rtems-devel mailing list
rtems-devel at rtems.org<mailto:rtems-devel at rtems.org>
http://www.rtems.org/mailman/listinfo/rtems-devel



_______________________________________________
rtems-devel mailing list
rtems-devel at rtems.org<mailto:rtems-devel at rtems.org>
http://www.rtems.org/mailman/listinfo/rtems-devel




--
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com<mailto:joel.sherrill at OARcorp.com>        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985

-------------- next part --------------
A non-text attachment was scrubbed...
Name: psxtests_compiler_warnings.patch
Type: text/x-patch
Size: 23353 bytes
Desc: psxtests_compiler_warnings.patch
URL: <http://lists.rtems.org/pipermail/devel/attachments/20130822/836d905f/attachment.bin>


More information about the devel mailing list