From 18a71d8af56f4a70c9257608eb6e71b9cdc9f2ae Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Wed, 2 Dec 2020 18:45:16 +0100 Subject: stats: char-pointer arithmetic style-up Char* typed shared_header value appears multiple times, so store it is a variable. Pointer "p" value is used more frequently casted to char*, so use that type for it, and convert to void* only at return. Type: style Fixes: 41f15ae1dfd4ac1777b684fdc763d12496209418 Change-Id: I7b3f1e6a43c020acd7ae561f87d12237b07fcd66 Signed-off-by: Vratko Polak --- src/vpp-api/client/stat_client.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/vpp-api/client') diff --git a/src/vpp-api/client/stat_client.h b/src/vpp-api/client/stat_client.h index b2457ad6e48..730badd1728 100644 --- a/src/vpp-api/client/stat_client.h +++ b/src/vpp-api/client/stat_client.h @@ -101,12 +101,10 @@ _time_now_nsec (void) static inline void * stat_segment_adjust (stat_client_main_t * sm, void *data) { - void *p = (void *) ((char *) sm->shared_header + - ((char *) data - (char *) sm->shared_header->base)); - if ((char *) p > (char *) sm->shared_header && - (((char *) p + sizeof (p)) < - ((char *) sm->shared_header + sm->memory_size))) - return p; + char *csh = (char *) sm->shared_header; + char *p = csh + ((char *) data - (char *) sm->shared_header->base); + if (p > csh && p + sizeof (p) < csh + sm->memory_size) + return (void *) p; return 0; } -- cgit 1.2.3-korg