right shift count warning fixes

Mike McCormack mike at codeweavers.com
Fri Jun 17 02:43:43 CDT 2005


I get 3 warnings, when compiling Wine without any extra -W flags. They 
are all of the following kind:

config.c: In function `init_server_dir':
config.c:125: warning: right shift count >= width of type

The following patch fixes them.  Is "long long" portable enough, should 
I use __int64, LONGLONG or something else?

It would be nice to fix these so I can compile with -Werror ... useful 
for finding problems caused by other patches, like the next one I'll 
submit...

Mike
-------------- next part --------------
Index: libs/wine/config.c
===================================================================
RCS file: /home/wine/wine/libs/wine/config.c,v
retrieving revision 1.12
diff -u -p -r1.12 config.c
--- libs/wine/config.c	20 Dec 2004 18:55:18 -0000	1.12
+++ libs/wine/config.c	17 Jun 2005 07:38:48 -0000
@@ -104,6 +104,8 @@ inline static void remove_trailing_slash
 /* initialize the server directory value */
 static void init_server_dir( dev_t dev, ino_t ino )
 {
+    unsigned long long l_ino = ino;
+    unsigned long long l_dev = dev;
     char *p;
 #ifdef HAVE_GETUID
     const unsigned int uid = getuid();
@@ -116,15 +118,15 @@ static void init_server_dir( dev_t dev, 
     sprintf( server_dir, "%s%u%s", server_root_prefix, uid, server_dir_prefix );
     p = server_dir + strlen(server_dir);
 
-    if (sizeof(dev) > sizeof(unsigned long) && dev > ~0UL)
-        p += sprintf( p, "%lx%08lx-", (unsigned long)(dev >> 32), (unsigned long)dev );
+    if (sizeof(l_dev) > sizeof(unsigned long) && l_dev > ~0UL)
+        p += sprintf( p, "%lx%08lx-", (unsigned long)(l_dev >> 32), (unsigned long)l_dev );
     else
-        p += sprintf( p, "%lx-", (unsigned long)dev );
+        p += sprintf( p, "%lx-", (unsigned long)l_dev );
 
-    if (sizeof(ino) > sizeof(unsigned long) && ino > ~0UL)
-        sprintf( p, "%lx%08lx", (unsigned long)(ino >> 32), (unsigned long)ino );
+    if (sizeof(l_ino) > sizeof(unsigned long) && l_ino > ~0UL)
+        sprintf( p, "%lx%08lx", (unsigned long)(l_ino >> 32), (unsigned long)l_ino );
     else
-        sprintf( p, "%lx", (unsigned long)ino );
+        sprintf( p, "%lx", (unsigned long)l_ino );
 }
 
 /* initialize all the paths values */
Index: dlls/ntdll/virtual.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/virtual.c,v
retrieving revision 1.51
diff -u -p -r1.51 virtual.c
--- dlls/ntdll/virtual.c	6 Jun 2005 20:13:08 -0000	1.51
+++ dlls/ntdll/virtual.c	17 Jun 2005 07:38:49 -0000
@@ -648,7 +648,9 @@ static void *unaligned_mmap( void *addr,
                              unsigned int flags, int fd, off_t offset )
 {
 #if defined(linux) && defined(__i386__) && defined(__GNUC__)
-    if (!(offset >> 32) && (offset & page_mask))
+    long long l_ofs = offset;
+
+    if ( !(l_ofs >> 32) && (l_ofs & page_mask))
     {
         int ret;
 
Index: server/fd.c
===================================================================
RCS file: /home/wine/wine/server/fd.c,v
retrieving revision 1.41
diff -u -p -r1.41 fd.c
--- server/fd.c	10 Jun 2005 19:54:46 -0000	1.41
+++ server/fd.c	17 Jun 2005 07:38:49 -0000
@@ -580,10 +580,12 @@ static void inode_close_pending( struct 
 static void inode_dump( struct object *obj, int verbose )
 {
     struct inode *inode = (struct inode *)obj;
+    ULONGLONG ino = inode->ino;
+    ULONGLONG dev = inode->dev;
     fprintf( stderr, "Inode dev=" );
-    DUMP_LONG_LONG( inode->dev );
+    DUMP_LONG_LONG( dev );
     fprintf( stderr, " ino=" );
-    DUMP_LONG_LONG( inode->ino );
+    DUMP_LONG_LONG( ino );
     fprintf( stderr, "\n" );
 }
 


More information about the wine-patches mailing list