bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/5] tmpfile: fix pointer cast warning


From: Mike Frysinger
Subject: [PATCH 4/5] tmpfile: fix pointer cast warning
Date: Thu, 11 Aug 2016 20:30:49 +0800

On systems where sizeof(void*) != sizeof(unsigned int) (e.g. on most
64-bit platforms), we get a warning like so:
tmpfile.c: In function 'sh_seedrand':
tmpfile.c:128:61: warning: cast from pointer to integer of different size 
[-Wpointer-to-int-cast]
       srandom (tv.tv_sec ^ tv.tv_usec ^ (getpid () << 16) ^ (unsigned int)&d);

Use the standard uintptr_t to turn the pointer into an integer.
---
 lib/sh/tmpfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/sh/tmpfile.c b/lib/sh/tmpfile.c
index 7c2fbf22fbe6..e41e45bd7cac 100644
--- a/lib/sh/tmpfile.c
+++ b/lib/sh/tmpfile.c
@@ -125,7 +125,7 @@ sh_seedrand ()
       struct timeval tv;
              
       gettimeofday (&tv, NULL);
-      srandom (tv.tv_sec ^ tv.tv_usec ^ (getpid () << 16) ^ (unsigned int)&d);
+      srandom (tv.tv_sec ^ tv.tv_usec ^ (getpid () << 16) ^ (uintptr_t)&d);
       seeded = 1;
     }
 #endif
-- 
2.9.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]