After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 794651 - Posix.major()/minor() are missing #include <sys/sysmacros.h>
Posix.major()/minor() are missing #include <sys/sysmacros.h>
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings
0.40.x
Other Linux
: Normal normal
: 0.42
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2018-03-24 12:12 UTC by Martin Pitt
Modified: 2018-03-24 20:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
reproducer (262 bytes, text/x-vala)
2018-03-24 12:12 UTC, Martin Pitt
  Details
posix: Include sys/sysmacros.h for major(), minor() and makedev() (1.03 KB, patch)
2018-03-24 13:11 UTC, Rico Tzschichholz
committed Details | Review

Description Martin Pitt 2018-03-24 12:12:05 UTC
Created attachment 370082 [details]
reproducer

With glibc 2.26, the attached test program that exercises Posix.major() and minor() builds with a warning, but still works:

$ valac --pkg posix -o /tmp/out major.vala 
/home/martin/src/test/vala/major.vala.c: In Funktion »_vala_main«:
/home/martin/src/test/vala/major.vala.c:43:13: Warnung: In the GNU C Library, "major" is defined
 by <sys/sysmacros.h>. For historical compatibility, it is
 currently defined by <sys/types.h> as well, but we plan to
 remove this soon. To use "major", include <sys/sysmacros.h>
 directly. If you did not intend to use a system-defined macro
 "major", you should undefine it after including <sys/types.h>.
  _tmp6_ = major (_tmp5_);
             ^~~~~~~~~~~~~                                                                                                                                                                                                                                                                                                                                                           
/home/martin/src/test/vala/major.vala.c:46:13: Warnung: In the GNU C Library, "minor" is defined
 by <sys/sysmacros.h>. For historical compatibility, it is
 currently defined by <sys/types.h> as well, but we plan to
 remove this soon. To use "minor", include <sys/sysmacros.h>
 directly. If you did not intend to use a system-defined macro
 "minor", you should undefine it after including <sys/types.h>.
  _tmp9_ = minor (_tmp8_);
             ^~~~~~~~~~~~~                                            

But with glibc 2.27 (as in Fedora Rawhide) it does not work any more, as sys/types.h is now not sufficient any more:

$ valac --pkg posix -o /tmp/out major.vala
/home/martin/src/test/vala/major.vala.c: In function ‘_vala_main’:
/home/martin/src/test/vala/major.vala.c:48:45: warning: implicit declaration of function ‘major’ [-Wimplicit-function-declaration]
  fprintf (_tmp3_, "major: %u, minor: %u\n", major (_tmp5_), minor (_tmp7_));
                                             ^~~~~
/home/martin/src/test/vala/major.vala.c:48:61: warning: implicit declaration of function ‘minor’; did you mean ‘mknod’? [-Wimplicit-function-declaration]
  fprintf (_tmp3_, "major: %u, minor: %u\n", major (_tmp5_), minor (_tmp7_));
                                                             ^~~~~
                                                             mknod
/tmp/ccZtOWCJ.o: In function `_vala_main':
major.vala.c:(.text+0x37a): undefined reference to `minor'
major.vala.c:(.text+0x38d): undefined reference to `major'
collect2: error: ld returned 1 exit status
Comment 1 Rico Tzschichholz 2018-03-24 13:11:33 UTC
Created attachment 370083 [details] [review]
posix: Include sys/sysmacros.h for major(), minor() and makedev()

Relying on sys/types.h is fatal since glibc 2.27 and was deprecated since
glibc 2.25.
Comment 2 Rico Tzschichholz 2018-03-24 15:24:13 UTC
Works with glibc 2.23 on Ubuntu 16.04 and eglibc 2.19 on Ubuntu 14.04, so this should be good to go, even for backporting.
Comment 3 Rico Tzschichholz 2018-03-24 15:54:38 UTC
Attachment 370083 [details] pushed as 0277ea7 - posix: Include sys/sysmacros.h for major(), minor() and makedev()
Comment 4 Martin Pitt 2018-03-24 20:59:15 UTC
Thanks Rico!