Skip to contentSkip to conversation

libxl: build error

DISCUSSION Christoph Egger 4 participants 6 messages Oct 24, 2012 – Oct 25, 2012

lore
Share & tools
lore
#0 lore raw

Hi,

I have this build error:

xl_cmdimpl.c:3724:40: error: declaration of 'reboot' shadows a global declaration

Renaming it to '_reboot' fixes this for me.

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#1 lore raw
Quoted 6 lines · Christoph Egger

Hi,

I have this build error:

xl_cmdimpl.c:3724:40: error: declaration of 'reboot' shadows a global declaration

Did gcc tell you where the other global definition was from? reboot(2) I suppose?

Quoted 1 line

Renaming it to '_reboot' fixes this for me.

Can you send a patch?

I don't think _reboot is a legal identifier (reserved for the implementation or POSIX or some such). do_reboot would be ok. So would changing main_shutdown_or_reboot to take the function pointer directly I think.

Ian.

#2 lore raw
Quoted 9 lines · Ian Campbell
Quoted 6 lines · Christoph Egger

Hi,

I have this build error:

xl_cmdimpl.c:3724:40: error: declaration of 'reboot' shadows a global declaration

Did gcc tell you where the other global definition was from?

No.

Quoted 1 line

reboot(2) I suppose?

Yes. <unistd.h> has the prototype.

Quoted 8 lines
Quoted 1 line

Renaming it to '_reboot' fixes this for me.

Can you send a patch?

I don't think _reboot is a legal identifier (reserved for the implementation or POSIX or some such). do_reboot would be ok. So would changing main_shutdown_or_reboot to take the function pointer directly I think.

patch attached.

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
tools/libxl/xl_cmdimpl.c +2 -2
diff -r ac870df4f165 tools/libxl/xl_cmdimpl.c
@@ -3721,11 +3721,11 @@ int main_destroy(int argc, char **argv)
     return 0;
 }
 
-static int main_shutdown_or_reboot(int reboot, int argc, char **argv)
+static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
 {
     void (*fn)(uint32_t domid,
                libxl_evgen_domain_death **, libxl_ev_user, int) =
-        reboot ? &reboot_domain : &shutdown_domain;
+        do_reboot ? &reboot_domain : &shutdown_domain;
     int opt, i, nb_domain;
     int wait_for_it = 0, all =0;
     int fallback_trigger = 0;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Christoph Egger
Quoted 8 lines · Ian Campbell
Quoted 6 lines · Christoph Egger

Hi,

I have this build error:

xl_cmdimpl.c:3724:40: error: declaration of 'reboot' shadows a global declaration

Quoted 7 lines
Quoted 1 line

Did gcc tell you where the other global definition was from?

No.

Quoted 1 line

reboot(2) I suppose?

Yes. <unistd.h> has the prototype.

Afaict that's a mistake of whatever provides this header on your system - there's no unconditionally visible "reboot" in the specs I have available.

Jan

#4 lore raw
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Christoph Egger
Quoted 9 lines · Ian Campbell
Quoted 6 lines · Christoph Egger

Hi,

I have this build error:

xl_cmdimpl.c:3724:40: error: declaration of 'reboot' shadows a global declaration

Did gcc tell you where the other global definition was from?

No.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

reboot(2) I suppose?

Yes. <unistd.h> has the prototype.

Afaict that's a mistake of whatever provides this header on your system - there's no unconditionally visible "reboot" in the specs I have available.

Indeed, on Linux it is documented as requiring:

     #include <unistd.h>
     #include <sys/reboot.h>

(or sometimes linux/reboot.h).

Ian.

Acked-by
#5 lore raw

Re: libxl: build error [and 1 more messages]

In reply to Christoph Egger

Christoph Egger writes ("Re: [Xen-devel] libxl: build error"):

Quoted 1 line

patch attached.

Thanks. I have applied this. NB in future it would be helpful for you to supply a suitable commit message. In this case I wrote one - see below.

Quoted 3 lines · Jan Beulich

Afaict that's a mistake of whatever provides this header on your system - there's no unconditionally visible "reboot" in the specs I have available.

This is true, but I think it's a very forgiveable error and we might well end up including various headers which import os-specific names. So Christoph's patch is the right thing to do.

Ian.

# HG changeset patch
# User Christoph Egger <[email protected]> # Date 1351165885 -3600
# Node ID 580aa3946f87eb56690671bf1aa0022228f59c8c # Parent 22e08c9ac770db07c3c3e7c844aa7153050939f3
xl: avoid shadowing reboot(2)

On NetBSD <unistd.h> mistakenly exposes reboot(2). Work around this.

tools/libxl/xl_cmdimpl.c +2 -2
diff -r 22e08c9ac770 -r 580aa3946f87 tools/libxl/xl_cmdimpl.c
@@ -3721,11 +3721,11 @@ int main_destroy(int argc, char **argv)
     return 0;
 }
 
-static int main_shutdown_or_reboot(int reboot, int argc, char **argv)
+static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
 {
     void (*fn)(uint32_t domid,
                libxl_evgen_domain_death **, libxl_ev_user, int) =
-        reboot ? &reboot_domain : &shutdown_domain;
+        do_reboot ? &reboot_domain : &shutdown_domain;
     int opt, i, nb_domain;
     int wait_for_it = 0, all =0;
     int fallback_trigger = 0;