sparse on Ubuntu 18.04

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

 



Having recently installed Ubuntu 18.04, I found that running sparse over
the git source spews many warnings against a system header file:

  $ pwd
  /home/ramsay/git
  $ make abspath.sp
      SP abspath.c
  /usr/include/x86_64-linux-gnu/sys/sysmacros.h:79:1: warning: constant 0xfffff00000000000u is so big it is unsigned long
  /usr/include/x86_64-linux-gnu/sys/sysmacros.h:80:1: warning: constant 0x00000ffffff00000u is so big it is unsigned long

[I'm not sure, but I think these are the same warnings left on fedora 27
after Luc's recent __Float128 patches.]

Those sparse warnings are issued for each source file. After a quick look
at the system headers, I came up with this fix:

  $ mkdir bits
  $ cp /usr/include/x86_64-linux-gnu/bits/sysmacros.h bits
  $ vim bits/sysmacros.h 
  $ diff -u /usr/include/x86_64-linux-gnu/bits/sysmacros.h bits/sysmacros.h
  --- /usr/include/x86_64-linux-gnu/bits/sysmacros.h	2018-04-16 21:14:20.000000000 +0100
  +++ bits/sysmacros.h	2018-05-18 21:39:48.206065138 +0100
  @@ -40,8 +40,8 @@
     __SYSMACROS_DECLARE_MAJOR (DECL_TEMPL)			\
     {								\
       unsigned int __major;					\
  -    __major  = ((__dev & (__dev_t) 0x00000000000fff00u) >>  8); \
  -    __major |= ((__dev & (__dev_t) 0xfffff00000000000u) >> 32); \
  +    __major  = ((__dev & (__dev_t) 0x00000000000fff00UL) >>  8); \
  +    __major |= ((__dev & (__dev_t) 0xfffff00000000000UL) >> 32); \
       return __major;						\
     }
   
  @@ -52,8 +52,8 @@
     __SYSMACROS_DECLARE_MINOR (DECL_TEMPL)			\
     {								\
       unsigned int __minor;					\
  -    __minor  = ((__dev & (__dev_t) 0x00000000000000ffu) >>  0); \
  -    __minor |= ((__dev & (__dev_t) 0x00000ffffff00000u) >> 12); \
  +    __minor  = ((__dev & (__dev_t) 0x00000000000000ffUL) >>  0); \
  +    __minor |= ((__dev & (__dev_t) 0x00000ffffff00000UL) >> 12); \
       return __minor;						\
     }
   
  $ make abspath.sp
      SP abspath.c
  $ 
 
Note that this header is a (64-bit) platform specific file; a different
platform may require a different solution. (e.g. on a 32-bit platform it
may well be s/u/ULL/, for example - effectively the UINT64_C macro!)

I don't know how or where to submit this as a bug report against glibc
(mail to debian-glibc@xxxxxxxxxxxxxxxx, perhaps?). Does anyone here
have any pointers?

ATB,
Ramsay Jones
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux