* [PATCH libibverbs] memory: use SCNxPTR format to read uintptr_t values @ 2012-07-11 15:10 Yann Droneaud [not found] ` <1342019435-10041-1-git-send-email-ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Yann Droneaud @ 2012-07-11 15:10 UTC (permalink / raw) To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Yann Droneaud SCNxPTR is the correct format to parse uintptr_t hexadecimal values, whatever the width of uintptr_t type. This fix a warning when building on a 32bits system. Signed-off-by: Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org> --- src/memory.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/memory.c b/src/memory.c index ea9e712..7d97e55 100644 --- a/src/memory.c +++ b/src/memory.c @@ -44,6 +44,7 @@ #include <string.h> #include <dirent.h> #include <limits.h> +#include <inttypes.h> #include "ibverbs.h" @@ -116,7 +117,7 @@ static unsigned long get_page_size(void *base) int n; uintptr_t range_start, range_end; - n = sscanf(buf, "%lx-%lx", &range_start, &range_end); + n = sscanf(buf, "%" SCNxPTR "-%" SCNxPTR, &range_start, &range_end); if (n < 2) continue; -- 1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 4+ messages in thread
[parent not found: <1342019435-10041-1-git-send-email-ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH libibverbs] memory: use SCNxPTR format to read uintptr_t values [not found] ` <1342019435-10041-1-git-send-email-ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org> @ 2012-07-11 15:47 ` Roland Dreier [not found] ` <CAL1RGDUQiWdSYbCH8k7Bwu8y549wQtQ7=tPA1G=uJuGW76G4hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Roland Dreier @ 2012-07-11 15:47 UTC (permalink / raw) To: Yann Droneaud; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA On Wed, Jul 11, 2012 at 8:10 AM, Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org> wrote: > @@ -116,7 +117,7 @@ static unsigned long get_page_size(void *base) > int n; > uintptr_t range_start, range_end; > > - n = sscanf(buf, "%lx-%lx", &range_start, &range_end); > + n = sscanf(buf, "%" SCNxPTR "-%" SCNxPTR, &range_start, &range_end); > > if (n < 2) > continue; Looks fine in itself, and I don't necessarily expect you to be the one to answer, but: - what does /proc/<pid>/maps show when running a 32-bit process on a 64-bit kernel? Should we be using uint64_t / SCNx64? (but surely 32-bit processes are guaranteed to have all their mappings fit into 32 bits) - earlier in this function, why do we do /proc/%d/maps, getpid()? Why doesn't /proc/self/maps always work? Thanks, Roland -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CAL1RGDUQiWdSYbCH8k7Bwu8y549wQtQ7=tPA1G=uJuGW76G4hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH libibverbs] memory: use SCNxPTR format to read uintptr_t values [not found] ` <CAL1RGDUQiWdSYbCH8k7Bwu8y549wQtQ7=tPA1G=uJuGW76G4hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2012-07-11 16:09 ` Jason Gunthorpe 2012-07-11 16:17 ` Yann Droneaud 1 sibling, 0 replies; 4+ messages in thread From: Jason Gunthorpe @ 2012-07-11 16:09 UTC (permalink / raw) To: Roland Dreier; +Cc: Yann Droneaud, linux-rdma-u79uwXL29TY76Z2rM5mHXA On Wed, Jul 11, 2012 at 08:47:05AM -0700, Roland Dreier wrote: > Looks fine in itself, and I don't necessarily expect you to be the one > to answer, but: > > - what does /proc/<pid>/maps show when running a 32-bit process on a 64-bit > kernel? Should we be using uint64_t / SCNx64? (but surely 32-bit processes > are guaranteed to have all their mappings fit into 32 bits) Linux 2.6.35.9 #3 Wed Jan 5 12:06:51 MST 2011 x86_64 GNU/Linux 08048000-08052000 r-xp 00000000 ca:00 32652 /bin/cat So PTR seems right.. Jason -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH libibverbs] memory: use SCNxPTR format to read uintptr_t values [not found] ` <CAL1RGDUQiWdSYbCH8k7Bwu8y549wQtQ7=tPA1G=uJuGW76G4hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2012-07-11 16:09 ` Jason Gunthorpe @ 2012-07-11 16:17 ` Yann Droneaud 1 sibling, 0 replies; 4+ messages in thread From: Yann Droneaud @ 2012-07-11 16:17 UTC (permalink / raw) To: Roland Dreier; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA Le mercredi 11 juillet 2012 à 08:47 -0700, Roland Dreier a écrit : > On Wed, Jul 11, 2012 at 8:10 AM, Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org> wrote: > > @@ -116,7 +117,7 @@ static unsigned long get_page_size(void *base) > > int n; > > uintptr_t range_start, range_end; > > > > - n = sscanf(buf, "%lx-%lx", &range_start, &range_end); > > + n = sscanf(buf, "%" SCNxPTR "-%" SCNxPTR, &range_start, &range_end); > > > > if (n < 2) > > continue; > > Looks fine in itself, and I don't necessarily expect you to be the one > to answer, but: > > - what does /proc/<pid>/maps show when running a 32-bit process on a 64-bit > kernel? Should we be using uint64_t / SCNx64? (but surely 32-bit processes > are guaranteed to have all their mappings fit into 32 bits) > "maps" file is presented to 32bits process as a 32bits mapping. > - earlier in this function, why do we do /proc/%d/maps, getpid()? Why doesn't > /proc/self/maps always work? > I think /proc/self/maps would always work here. Using explicitly the pid could be of use for the child to read its parent mapping. Regards -- Yann Droneaud OPTEYA -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-11 16:17 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-07-11 15:10 [PATCH libibverbs] memory: use SCNxPTR format to read uintptr_t values Yann Droneaud [not found] ` <1342019435-10041-1-git-send-email-ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org> 2012-07-11 15:47 ` Roland Dreier [not found] ` <CAL1RGDUQiWdSYbCH8k7Bwu8y549wQtQ7=tPA1G=uJuGW76G4hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2012-07-11 16:09 ` Jason Gunthorpe 2012-07-11 16:17 ` Yann Droneaud
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.