debuggers.hg

changeset 22062:e5a9221bdd3f

tools/libxl: compile with -Wmissing-declarations

Since the recent build error caused by mismatch of symbol types due to
missing declarations, build libxl with -Wmissing-declarations.

The patch is mostly straightforward, a one liner in the makefile enables
the flag, a lot of functions in xl_cmdimpl.c needed to be made static
and libxl_paths.c needed to include libxl.h.

The one wart on the patch-set is that flex has a bug where it emits code
with missing declarations for yy(set|get)_column. This can be worked
around by providing the declarations ourselves regardless.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Ian Jackson <Ian.Jackson@eu.citrix.com>
date Tue Aug 17 17:20:53 2010 +0100 (2010-08-17)
parents c82f7f4ee9b7
children ca50b3d02b29
files tools/libxl/Makefile tools/libxl/libxl.c tools/libxl/libxl_device.c tools/libxl/libxl_internal.h tools/libxl/libxl_paths.c tools/libxl/libxlu_cfg_l.c tools/libxl/libxlu_cfg_l.h tools/libxl/libxlu_cfg_l.l tools/libxl/xl_cmdimpl.c
line diff
     1.1 --- a/tools/libxl/Makefile	Tue Aug 17 15:23:36 2010 +0100
     1.2 +++ b/tools/libxl/Makefile	Tue Aug 17 17:20:53 2010 +0100
     1.3 @@ -11,7 +11,7 @@ MINOR = 0
     1.4  XLUMAJOR = 1.0
     1.5  XLUMINOR = 0
     1.6  
     1.7 -CFLAGS += -Werror -Wno-format-zero-length
     1.8 +CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations
     1.9  CFLAGS += -I. -fPIC
    1.10  CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
    1.11  
     2.1 --- a/tools/libxl/libxl.c	Tue Aug 17 15:23:36 2010 +0100
     2.2 +++ b/tools/libxl/libxl.c	Tue Aug 17 17:20:53 2010 +0100
     2.3 @@ -1346,7 +1346,7 @@ static char ** libxl_build_device_model_
     2.4      }
     2.5  }
     2.6  
     2.7 -void dm_xenstore_record_pid(void *for_spawn, pid_t innerchild)
     2.8 +static void dm_xenstore_record_pid(void *for_spawn, pid_t innerchild)
     2.9  {
    2.10      libxl_device_model_starting *starting = for_spawn;
    2.11      char *kvs[3];
     3.1 --- a/tools/libxl/libxl_device.c	Tue Aug 17 15:23:36 2010 +0100
     3.2 +++ b/tools/libxl/libxl_device.c	Tue Aug 17 17:20:53 2010 +0100
     3.3 @@ -262,7 +262,7 @@ out:
     3.4      return rc;
     3.5  }
     3.6  
     3.7 -int wait_for_dev_destroy(libxl_ctx *ctx, struct timeval *tv)
     3.8 +static int wait_for_dev_destroy(libxl_ctx *ctx, struct timeval *tv)
     3.9  {
    3.10      libxl_gc gc = LIBXL_INIT_GC(ctx);
    3.11      int nfds, rc;
     4.1 --- a/tools/libxl/libxl_internal.h	Tue Aug 17 15:23:36 2010 +0100
     4.2 +++ b/tools/libxl/libxl_internal.h	Tue Aug 17 17:20:53 2010 +0100
     4.3 @@ -272,4 +272,6 @@ struct libxl__xen_console_reader {
     4.4      unsigned int index;
     4.5  };
     4.6  
     4.7 +_hidden int libxl_error_set(libxl_ctx *ctx, int code);
     4.8 +
     4.9  #endif
     5.1 --- a/tools/libxl/libxl_paths.c	Tue Aug 17 15:23:36 2010 +0100
     5.2 +++ b/tools/libxl/libxl_paths.c	Tue Aug 17 17:20:53 2010 +0100
     5.3 @@ -12,6 +12,7 @@
     5.4   * GNU Lesser General Public License for more details.
     5.5   */
     5.6  
     5.7 +#include "libxl.h"
     5.8  #include "_libxl_paths.h"
     5.9  
    5.10  const char *libxl_sbindir_path(void)
     6.1 --- a/tools/libxl/libxlu_cfg_l.c	Tue Aug 17 15:23:36 2010 +0100
     6.2 +++ b/tools/libxl/libxlu_cfg_l.c	Tue Aug 17 17:20:53 2010 +0100
     6.3 @@ -488,8 +488,15 @@ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
     6.4      return (x);                   \
     6.5    }while(0)
     6.6  
     6.7 +/* Some versions of flex have a bug (Fedora bugzilla 612465) which causes
     6.8 + * it to fail to declare these functions, which it defines.  So declare
     6.9 + * them ourselves.  Hopefully we won't have to simultaneously support
    6.10 + * a flex version which declares these differently somehow. */
    6.11 +int xlu__cfg_yyget_column(yyscan_t yyscanner);
    6.12 +void xlu__cfg_yyset_column(int  column_no, yyscan_t yyscanner);
    6.13  
    6.14 -#line 493 "libxlu_cfg_l.c"
    6.15 +
    6.16 +#line 500 "libxlu_cfg_l.c"
    6.17  
    6.18  #define INITIAL 0
    6.19  #define lexerr 1
    6.20 @@ -734,10 +741,10 @@ YY_DECL
    6.21  	register int yy_act;
    6.22      struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    6.23  
    6.24 -#line 30 "libxlu_cfg_l.l"
    6.25 +#line 37 "libxlu_cfg_l.l"
    6.26  
    6.27  
    6.28 -#line 741 "libxlu_cfg_l.c"
    6.29 +#line 748 "libxlu_cfg_l.c"
    6.30  
    6.31      yylval = yylval_param;
    6.32  
    6.33 @@ -840,7 +847,7 @@ do_action:	/* This label is used only to
    6.34  
    6.35  case 1:
    6.36  YY_RULE_SETUP
    6.37 -#line 32 "libxlu_cfg_l.l"
    6.38 +#line 39 "libxlu_cfg_l.l"
    6.39  {
    6.40                            yylval->string= xlu__cfgl_strdup(ctx,yytext);
    6.41                            GOT(IDENT);
    6.42 @@ -848,7 +855,7 @@ YY_RULE_SETUP
    6.43  	YY_BREAK
    6.44  case 2:
    6.45  YY_RULE_SETUP
    6.46 -#line 36 "libxlu_cfg_l.l"
    6.47 +#line 43 "libxlu_cfg_l.l"
    6.48  {
    6.49                            yylval->string= xlu__cfgl_strdup(ctx,yytext);
    6.50                            GOT(NUMBER);
    6.51 @@ -856,43 +863,43 @@ YY_RULE_SETUP
    6.52  	YY_BREAK
    6.53  case 3:
    6.54  YY_RULE_SETUP
    6.55 -#line 41 "libxlu_cfg_l.l"
    6.56 +#line 48 "libxlu_cfg_l.l"
    6.57  
    6.58  	YY_BREAK
    6.59  case 4:
    6.60  YY_RULE_SETUP
    6.61 -#line 43 "libxlu_cfg_l.l"
    6.62 +#line 50 "libxlu_cfg_l.l"
    6.63  { GOT(','); }
    6.64  	YY_BREAK
    6.65  case 5:
    6.66  YY_RULE_SETUP
    6.67 -#line 44 "libxlu_cfg_l.l"
    6.68 +#line 51 "libxlu_cfg_l.l"
    6.69  { GOT('['); }
    6.70  	YY_BREAK
    6.71  case 6:
    6.72  YY_RULE_SETUP
    6.73 -#line 45 "libxlu_cfg_l.l"
    6.74 +#line 52 "libxlu_cfg_l.l"
    6.75  { GOT(']'); }
    6.76  	YY_BREAK
    6.77  case 7:
    6.78  YY_RULE_SETUP
    6.79 -#line 46 "libxlu_cfg_l.l"
    6.80 +#line 53 "libxlu_cfg_l.l"
    6.81  { GOT('='); }
    6.82  	YY_BREAK
    6.83  case 8:
    6.84  YY_RULE_SETUP
    6.85 -#line 47 "libxlu_cfg_l.l"
    6.86 +#line 54 "libxlu_cfg_l.l"
    6.87  { GOT(';'); }
    6.88  	YY_BREAK
    6.89  case 9:
    6.90  /* rule 9 can match eol */
    6.91  YY_RULE_SETUP
    6.92 -#line 49 "libxlu_cfg_l.l"
    6.93 +#line 56 "libxlu_cfg_l.l"
    6.94  { yylloc->first_line= yylineno-1; return NEWLINE; }
    6.95  	YY_BREAK
    6.96  case 10:
    6.97  YY_RULE_SETUP
    6.98 -#line 51 "libxlu_cfg_l.l"
    6.99 +#line 58 "libxlu_cfg_l.l"
   6.100  {
   6.101                            yylval->string= xlu__cfgl_dequote(ctx,yytext);
   6.102                            GOT(STRING);
   6.103 @@ -900,7 +907,7 @@ YY_RULE_SETUP
   6.104  	YY_BREAK
   6.105  case 11:
   6.106  YY_RULE_SETUP
   6.107 -#line 55 "libxlu_cfg_l.l"
   6.108 +#line 62 "libxlu_cfg_l.l"
   6.109  {
   6.110                            yylval->string= xlu__cfgl_dequote(ctx,yytext);
   6.111                            GOT(STRING);
   6.112 @@ -908,7 +915,7 @@ YY_RULE_SETUP
   6.113  	YY_BREAK
   6.114  case 12:
   6.115  YY_RULE_SETUP
   6.116 -#line 60 "libxlu_cfg_l.l"
   6.117 +#line 67 "libxlu_cfg_l.l"
   6.118  {
   6.119                            BEGIN(lexerr);
   6.120                            yymore();
   6.121 @@ -916,7 +923,7 @@ YY_RULE_SETUP
   6.122  	YY_BREAK
   6.123  case 13:
   6.124  YY_RULE_SETUP
   6.125 -#line 65 "libxlu_cfg_l.l"
   6.126 +#line 72 "libxlu_cfg_l.l"
   6.127  {
   6.128                            xlu__cfgl_lexicalerror(ctx,"lexical error");
   6.129                            BEGIN(0);
   6.130 @@ -925,7 +932,7 @@ YY_RULE_SETUP
   6.131  case 14:
   6.132  /* rule 14 can match eol */
   6.133  YY_RULE_SETUP
   6.134 -#line 70 "libxlu_cfg_l.l"
   6.135 +#line 77 "libxlu_cfg_l.l"
   6.136  {
   6.137                            xlu__cfgl_lexicalerror(ctx,"lexical error");
   6.138                            BEGIN(0);
   6.139 @@ -934,10 +941,10 @@ YY_RULE_SETUP
   6.140  	YY_BREAK
   6.141  case 15:
   6.142  YY_RULE_SETUP
   6.143 -#line 75 "libxlu_cfg_l.l"
   6.144 +#line 82 "libxlu_cfg_l.l"
   6.145  YY_FATAL_ERROR( "flex scanner jammed" );
   6.146  	YY_BREAK
   6.147 -#line 941 "libxlu_cfg_l.c"
   6.148 +#line 948 "libxlu_cfg_l.c"
   6.149  case YY_STATE_EOF(INITIAL):
   6.150  case YY_STATE_EOF(lexerr):
   6.151  	yyterminate();
   6.152 @@ -2087,4 +2094,4 @@ void xlu__cfg_yyfree (void * ptr , yysca
   6.153  
   6.154  #define YYTABLES_NAME "yytables"
   6.155  
   6.156 -#line 75 "libxlu_cfg_l.l"
   6.157 +#line 82 "libxlu_cfg_l.l"
     7.1 --- a/tools/libxl/libxlu_cfg_l.h	Tue Aug 17 15:23:36 2010 +0100
     7.2 +++ b/tools/libxl/libxlu_cfg_l.h	Tue Aug 17 17:20:53 2010 +0100
     7.3 @@ -350,7 +350,7 @@ extern int xlu__cfg_yylex \
     7.4  #undef YY_DECL
     7.5  #endif
     7.6  
     7.7 -#line 75 "libxlu_cfg_l.l"
     7.8 +#line 82 "libxlu_cfg_l.l"
     7.9  
    7.10  #line 356 "libxlu_cfg_l.h"
    7.11  #undef xlu__cfg_yyIN_HEADER
     8.1 --- a/tools/libxl/libxlu_cfg_l.l	Tue Aug 17 15:23:36 2010 +0100
     8.2 +++ b/tools/libxl/libxlu_cfg_l.l	Tue Aug 17 17:20:53 2010 +0100
     8.3 @@ -11,6 +11,13 @@
     8.4      return (x);                   \
     8.5    }while(0)
     8.6  
     8.7 +/* Some versions of flex have a bug (Fedora bugzilla 612465) which causes
     8.8 + * it to fail to declare these functions, which it defines.  So declare
     8.9 + * them ourselves.  Hopefully we won't have to simultaneously support
    8.10 + * a flex version which declares these differently somehow. */
    8.11 +int xlu__cfg_yyget_column(yyscan_t yyscanner);
    8.12 +void xlu__cfg_yyset_column(int  column_no, yyscan_t yyscanner);
    8.13 +
    8.14  %}
    8.15  
    8.16  %option warn
     9.1 --- a/tools/libxl/xl_cmdimpl.c	Tue Aug 17 15:23:36 2010 +0100
     9.2 +++ b/tools/libxl/xl_cmdimpl.c	Tue Aug 17 17:20:53 2010 +0100
     9.3 @@ -214,7 +214,7 @@ static void find_domain(const char *p)
     9.4  
     9.5  #define LOG(_f, _a...)   dolog(__FILE__, __LINE__, __func__, _f "\n", ##_a)
     9.6  
     9.7 -void dolog(const char *file, int line, const char *func, char *fmt, ...)
     9.8 +static void dolog(const char *file, int line, const char *func, char *fmt, ...)
     9.9  {
    9.10      va_list ap;
    9.11      char *s;
    9.12 @@ -1037,7 +1037,7 @@ static void *xrealloc(void *ptr, size_t 
    9.13      return r;
    9.14  }
    9.15  
    9.16 -int autoconnect_console(int hvm)
    9.17 +static int autoconnect_console(int hvm)
    9.18  {
    9.19      int status, options;
    9.20      pid_t pid, r;
    9.21 @@ -1661,7 +1661,7 @@ static int64_t parse_mem_size_kb(char *m
    9.22      return kbytes;
    9.23  }
    9.24  
    9.25 -int set_memory_max(char *p, char *mem)
    9.26 +static int set_memory_max(char *p, char *mem)
    9.27  {
    9.28      int64_t memorykb;
    9.29      int rc;
    9.30 @@ -1712,7 +1712,7 @@ int main_memmax(int argc, char **argv)
    9.31      return 0;
    9.32  }
    9.33  
    9.34 -void set_memory_target(char *p, char *mem)
    9.35 +static void set_memory_target(char *p, char *mem)
    9.36  {
    9.37      long long int memorykb;
    9.38  
    9.39 @@ -1754,7 +1754,7 @@ int main_memset(int argc, char **argv)
    9.40      return 0;
    9.41  }
    9.42  
    9.43 -void cd_insert(char *dom, char *virtdev, char *phys)
    9.44 +static void cd_insert(char *dom, char *virtdev, char *phys)
    9.45  {
    9.46      libxl_device_disk disk;
    9.47      char *p;
    9.48 @@ -1936,7 +1936,7 @@ int main_vncviewer(int argc, char **argv
    9.49      return 0;
    9.50  }
    9.51  
    9.52 -void pcilist_assignable(void)
    9.53 +static void pcilist_assignable(void)
    9.54  {
    9.55      libxl_device_pci *pcidevs;
    9.56      int num, i;
    9.57 @@ -1969,7 +1969,7 @@ int main_pcilist_assignable(int argc, ch
    9.58      return 0;
    9.59  }
    9.60  
    9.61 -void pcilist(char *dom)
    9.62 +static void pcilist(char *dom)
    9.63  {
    9.64      libxl_device_pci *pcidevs;
    9.65      int num, i;
    9.66 @@ -2011,7 +2011,7 @@ int main_pcilist(int argc, char **argv)
    9.67      return 0;
    9.68  }
    9.69  
    9.70 -void pcidetach(char *dom, char *bdf)
    9.71 +static void pcidetach(char *dom, char *bdf)
    9.72  {
    9.73      libxl_device_pci pcidev;
    9.74  
    9.75 @@ -2051,7 +2051,7 @@ int main_pcidetach(int argc, char **argv
    9.76      pcidetach(domname, bdf);
    9.77      return 0;
    9.78  }
    9.79 -void pciattach(char *dom, char *bdf, char *vs)
    9.80 +static void pciattach(char *dom, char *bdf, char *vs)
    9.81  {
    9.82      libxl_device_pci pcidev;
    9.83  
    9.84 @@ -2095,19 +2095,19 @@ int main_pciattach(int argc, char **argv
    9.85      return 0;
    9.86  }
    9.87  
    9.88 -void pause_domain(char *p)
    9.89 +static void pause_domain(char *p)
    9.90  {
    9.91      find_domain(p);
    9.92      libxl_domain_pause(&ctx, domid);
    9.93  }
    9.94  
    9.95 -void unpause_domain(char *p)
    9.96 +static void unpause_domain(char *p)
    9.97  {
    9.98      find_domain(p);
    9.99      libxl_domain_unpause(&ctx, domid);
   9.100  }
   9.101  
   9.102 -void destroy_domain(char *p)
   9.103 +static void destroy_domain(char *p)
   9.104  {
   9.105      int rc;
   9.106      find_domain(p);
   9.107 @@ -2119,7 +2119,7 @@ void destroy_domain(char *p)
   9.108      if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n.",rc); exit(-1); }
   9.109  }
   9.110  
   9.111 -void shutdown_domain(char *p)
   9.112 +static void shutdown_domain(char *p)
   9.113  {
   9.114      int rc;
   9.115      find_domain(p);
   9.116 @@ -2127,7 +2127,7 @@ void shutdown_domain(char *p)
   9.117      if (rc) { fprintf(stderr,"shutdown failed (rc=%d)\n.",rc);exit(-1); }
   9.118  }
   9.119  
   9.120 -void reboot_domain(char *p)
   9.121 +static void reboot_domain(char *p)
   9.122  {
   9.123      int rc;
   9.124      find_domain(p);
   9.125 @@ -2135,7 +2135,7 @@ void reboot_domain(char *p)
   9.126      if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n.",rc);exit(-1); }
   9.127  }
   9.128  
   9.129 -void list_domains_details(const libxl_dominfo *info, int nb_domain)
   9.130 +static void list_domains_details(const libxl_dominfo *info, int nb_domain)
   9.131  {
   9.132      struct domain_config d_config;
   9.133  
   9.134 @@ -2161,7 +2161,7 @@ void list_domains_details(const libxl_do
   9.135      }
   9.136  }
   9.137  
   9.138 -void list_domains(int verbose, const libxl_dominfo *info, int nb_domain)
   9.139 +static void list_domains(int verbose, const libxl_dominfo *info, int nb_domain)
   9.140  {
   9.141      int i;
   9.142  
   9.143 @@ -2188,7 +2188,7 @@ void list_domains(int verbose, const lib
   9.144      }
   9.145  }
   9.146  
   9.147 -void list_vm(void)
   9.148 +static void list_vm(void)
   9.149  {
   9.150      libxl_vminfo *info;
   9.151      char *domname;
   9.152 @@ -2236,7 +2236,7 @@ static void save_domain_core_begin(char 
   9.153      }
   9.154  }
   9.155  
   9.156 -void save_domain_core_writeconfig(int fd, const char *filename,
   9.157 +static void save_domain_core_writeconfig(int fd, const char *filename,
   9.158                                    const uint8_t *config_data, int config_len)
   9.159  {
   9.160      struct save_file_header hdr;
   9.161 @@ -2275,7 +2275,7 @@ void save_domain_core_writeconfig(int fd
   9.162              hdr.optional_data_len);
   9.163  }
   9.164  
   9.165 -int save_domain(char *p, char *filename, int checkpoint,
   9.166 +static int save_domain(char *p, char *filename, int checkpoint,
   9.167                  const char *override_config_file)
   9.168  {
   9.169      int fd;
   9.170 @@ -3157,7 +3157,7 @@ int main_create(int argc, char **argv)
   9.171      return 0;
   9.172  }
   9.173  
   9.174 -void button_press(char *p, char *b)
   9.175 +static void button_press(char *p, char *b)
   9.176  {
   9.177      libxl_button button;
   9.178  
   9.179 @@ -3272,7 +3272,7 @@ static void print_vcpuinfo(uint32_t tdom
   9.180      }
   9.181  }
   9.182  
   9.183 -void vcpulist(int argc, char **argv)
   9.184 +static void vcpulist(int argc, char **argv)
   9.185  {
   9.186      libxl_dominfo *dominfo, *domlist;
   9.187      libxl_vcpuinfo *vcpuinfo, *list = NULL;
   9.188 @@ -3340,7 +3340,7 @@ int main_vcpulist(int argc, char **argv)
   9.189      return 0;
   9.190  }
   9.191  
   9.192 -void vcpupin(char *d, const char *vcpu, char *cpu)
   9.193 +static void vcpupin(char *d, const char *vcpu, char *cpu)
   9.194  {
   9.195      libxl_vcpuinfo *vcpuinfo;
   9.196      libxl_physinfo physinfo;
   9.197 @@ -3444,7 +3444,7 @@ int main_vcpupin(int argc, char **argv)
   9.198      return 0;
   9.199  }
   9.200  
   9.201 -void vcpuset(char *d, char* nr_vcpus)
   9.202 +static void vcpuset(char *d, char* nr_vcpus)
   9.203  {
   9.204      char *endptr;
   9.205      unsigned int max_vcpus;