[PATCH] Update:Change format specifiers to fix 4 warnings.

Joel Sherrill joel at rtems.org
Thu Apr 6 22:45:49 UTC 2017


I filed a ticket (https://devel.rtems.org/ticket/2983) so we can
fine tune the proposal and track it.

--joel

On Thu, Apr 6, 2017 at 5:39 PM, Joel Sherrill <joel at rtems.org> wrote:

>
>
> On Thu, Apr 6, 2017 at 5:37 PM, Gedare Bloom <gedare at rtems.org> wrote:
>
>> On Thu, Apr 6, 2017 at 6:30 PM, Joel Sherrill <joel at rtems.org> wrote:
>> > Following up on my own post. You can avoid some casts.
>> > This is also an example of how pulling a thread can lead
>> > somewhere more complicated. :)
>> >
>> > %z should work portably for size_t and should avoid a cast.
>> >
>> > libdl already has this in libdl/rtl-shell.c which tries to provide a
>> > C99 inttypes.h like constant.
>> >
>> > if defined(__moxie__)
>> > #define PRIdoff_t PRIo32
>> > #else
>> > #define PRIdoff_t PRIo64
>> > #endif
>> >
>> > Unfortunately, there is something similar defined in
>> > testsuites/psxtests/include/pmacros.h which looks to be
>> > better done.
>> >
>> > Searching in cpukit for similar code turns up a number of
>> > other types and repetitions.
>> >
>> > grep -r "#define PRI" . | grep -v PRIORITY | grep -v PRINT
>> >
>> > I would suggest the more elegant solution for the PRI constant
>> > off_t, time_t, and mode_t would be
>> > cpukit/include/rtems/inttypes_extensions.h
>> > and that the best of all the duplicated definitions be moved there.
>> > That centralizes them and them everyone uses the same ones.
>> >
>> It would be good to consolidate these. I'd suggest it comes in through
>> #include <rtems/inttypes.h>
>> without the _extensions bit is unnecessary if this is part of the
>> "RTEMS" headers.
>>
>> I think there are some problems with _ in file names for some platforms?
>>
>> > I suspect that many of the remaining printf format warnings can then
>> > be resolved using these helpers or by adding more.
>> >
>> Yes, and the rtems/inttypes.h should ideally pull in "Standard"
>> inttypes.h and then extends them.
>>
>> This would be my preference.
>>
>>
> Fine by me. I was toying with the same name and include idea.
>
> If we had been in a conference room, it would have taken 30 seconds
> to agree. :)
>
> --joel
>
>
>> > This idea needs a review and approval by at least one other
>> > developer. Especially the file name.
>> >
>> > --joel
>> >
>> >
>> > On Thu, Apr 6, 2017 at 4:10 PM, Cillian O'Donnell <
>> cpodonnell8 at gmail.com>
>> > wrote:
>> >>
>> >> 2 of the warnings cropped up on further testing of other BSPs. Sorry,
>> >> should of been more careful.
>> >> Also git send-email format.
>> >> ---
>> >>  cpukit/libdl/rtl-obj-cache.c | 18 +++++++++---------
>> >>  1 file changed, 9 insertions(+), 9 deletions(-)
>> >>
>> >> diff --git a/cpukit/libdl/rtl-obj-cache.c
>> b/cpukit/libdl/rtl-obj-cache.c
>> >> index a4676cf..d3cd953 100644
>> >> --- a/cpukit/libdl/rtl-obj-cache.c
>> >> +++ b/cpukit/libdl/rtl-obj-cache.c
>> >> @@ -78,11 +78,11 @@ rtems_rtl_obj_cache_read (rtems_rtl_obj_cache_t*
>> >> cache,
>> >>    struct stat sb;
>> >>
>> >>    if (rtems_rtl_trace (RTEMS_RTL_TRACE_CACHE))
>> >> -    printf ("rtl: cache: %2d: fd=%d offset=%d length=%d area=[%d,%d]
>> >> cache=[%d,%d] size=%d\n",
>> >> -            fd, cache->fd, (int) offset, (int) *length,
>> >> -            (int) offset, (int) offset + *length,
>> >> -            (int) cache->offset, (int) cache->offset + cache->level,
>> >> -            (int) cache->file_size);
>> >> +    printf ("rtl: cache: %2d: fd=%d offset=%llu length=%d
>> area=[%d,%llu]
>> >> cache=[%llu,%llu] size=%lu\n",
>> >> +            fd, cache->fd, offset, (int) *length,
>> >> +            (int) offset, offset + *length,
>> >> +            cache->offset, cache->offset + cache->level,
>> >> +            (unsigned long) cache->file_size);
>> >>
>> >>    if (*length > cache->size)
>> >>    {
>> >> @@ -172,10 +172,10 @@ rtems_rtl_obj_cache_read (rtems_rtl_obj_cache_t*
>> >> cache,
>> >>      }
>> >>
>> >>      if (rtems_rtl_trace (RTEMS_RTL_TRACE_CACHE))
>> >> -      printf ("rtl: cache: %2d: seek: offset=%d buffer_offset=%d
>> read=%d
>> >> cache=[%d,%d] dist=%d\n",
>> >> -              fd, (int) offset + buffer_offset, (int) buffer_offset,
>> >> (int) buffer_read,
>> >> -              (int) offset, (int) offset + buffer_read,
>> >> -              (int) (cache->file_size - offset));
>> >> +      printf ("rtl: cache: %2d: seek: offset=%llu buffer_offset=%lu
>> >> read=%d cache=[%d,%llu] dist=%llu\n",
>> >> +              fd, offset + buffer_offset, (unsigned long)
>> buffer_offset,
>> >> (int) buffer_read,
>> >> +              (int) offset, offset + buffer_read,
>> >> +              (cache->file_size - offset));
>> >>
>> >>      if (lseek (fd, offset + buffer_offset, SEEK_SET) < 0)
>> >>      {
>> >> --
>> >> 2.7.4
>> >>
>> >> _______________________________________________
>> >> devel mailing list
>> >> devel at rtems.org
>> >> http://lists.rtems.org/mailman/listinfo/devel
>> >
>> >
>> >
>> > _______________________________________________
>> > devel mailing list
>> > devel at rtems.org
>> > http://lists.rtems.org/mailman/listinfo/devel
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20170406/29f9af57/attachment-0002.html>


More information about the devel mailing list