Explorar el Código

Use new action_func typedef instead of ad-hoc function casts

Guillem Jover hace 15 años
padre
commit
12d1e5a1a4
Se han modificado 9 ficheros con 33 adiciones y 25 borrados
  1. 9 4
      dpkg-deb/dpkg-deb.h
  2. 2 2
      dpkg-deb/main.c
  3. 6 3
      dpkg-split/dpkg-split.h
  4. 2 2
      dpkg-split/main.c
  5. 3 3
      lib/dpkg/myopt.h
  6. 2 2
      src/divertcmd.c
  7. 5 5
      src/main.c
  8. 2 2
      src/querycmd.c
  9. 2 2
      src/statcmd.c

+ 9 - 4
dpkg-deb/dpkg-deb.h

@@ -21,10 +21,15 @@
 #ifndef DPKG_DEB_H
 #define DPKG_DEB_H
 
-typedef int dofunction(const char *const *argv);
-dofunction do_build;
-dofunction do_contents, do_control, do_showinfo;
-dofunction do_info, do_field, do_extract, do_vextract, do_fsystarfile;
+action_func do_build;
+action_func do_contents;
+action_func do_control;
+action_func do_showinfo;
+action_func do_info;
+action_func do_field;
+action_func do_extract;
+action_func do_vextract;
+action_func do_fsystarfile;
 
 extern int debugflag, nocheckflag, oldformatflag;
 

+ 2 - 2
dpkg-deb/main.c

@@ -182,7 +182,7 @@ static const struct cmdinfo cmdinfos[]= {
 };
 
 int main(int argc, const char *const *argv) {
-  dofunction *action;
+  action_func *action;
   int ret;
 
   setlocale(LC_NUMERIC, "POSIX");
@@ -196,7 +196,7 @@ int main(int argc, const char *const *argv) {
   if (!cipaction) badusage(_("need an action option"));
 
   unsetenv("GZIP");
-  action = (dofunction *)cipaction->arg_func;
+  action = cipaction->arg_func;
   ret = action(argv);
 
   standard_shutdown();

+ 6 - 3
dpkg-split/dpkg-split.h

@@ -21,9 +21,12 @@
 #ifndef DPKG_SPLIT_H
 #define DPKG_SPLIT_H
 
-typedef int dofunction(const char *const *argv);
-dofunction do_split;
-dofunction do_join, do_info, do_auto, do_queue, do_discard;
+action_func do_split;
+action_func do_join;
+action_func do_info;
+action_func do_auto;
+action_func do_queue;
+action_func do_discard;
 
 struct partinfo {
   const char *filename;

+ 2 - 2
dpkg-split/main.c

@@ -148,7 +148,7 @@ int main(int argc, const char *const *argv) {
   int ret;
   int l;
   char *p;
-  dofunction *action;
+  action_func *action;
 
   setlocale(LC_ALL, "");
   bindtextdomain(PACKAGE, LOCALEDIR);
@@ -168,7 +168,7 @@ int main(int argc, const char *const *argv) {
   }
 
   setvbuf(stdout,NULL,_IONBF,0);
-  action = (dofunction *)cipaction->arg_func;
+  action = cipaction->arg_func;
   ret = action(argv);
 
   m_output(stderr, _("<standard error>"));

+ 3 - 3
lib/dpkg/myopt.h

@@ -25,7 +25,7 @@
 
 DPKG_BEGIN_DECLS
 
-typedef void void_func(void);
+typedef int action_func(const char *const *argv);
 
 struct cmdinfo {
   const char *olong;
@@ -44,7 +44,7 @@ struct cmdinfo {
 
   int arg_int;
   void *arg_ptr;
-  void_func *arg_func;
+  action_func *arg_func;
 };
 
 extern const char printforhelp[];
@@ -66,7 +66,7 @@ void setaction(const struct cmdinfo *cip, const char *value);
 void setobsolete(const struct cmdinfo *cip, const char *value);
 
 #define ACTION(longopt, shortopt, code, func) \
- { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (void_func *)func }
+ { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, func }
 #define OBSOLETE(longopt, shortopt) \
  { longopt, shortopt, 0, NULL, NULL, setobsolete, 0, NULL, NULL }
 

+ 2 - 2
src/divertcmd.c

@@ -705,7 +705,7 @@ int
 main(int argc, const char * const *argv)
 {
 	const char *env_pkgname;
-	int (*actionfunction)(const char *const *argv);
+	action_func *actionfunction;
 	int ret;
 
 	setlocale(LC_ALL, "");
@@ -724,7 +724,7 @@ main(int argc, const char * const *argv)
 	if (!cipaction)
 		setaction(&cmdinfo_add, NULL);
 
-	actionfunction = (int (*)(const char *const *))cipaction->arg_func;
+	actionfunction = cipaction->arg_func;
 
 	setvbuf(stdout, NULL, _IONBF, 0);
 

+ 5 - 5
src/main.c

@@ -524,7 +524,7 @@ int commandfd(const char *const *argv);
  * have a very similar structure. */
 static const struct cmdinfo cmdinfos[]= {
 #define ACTIONBACKEND(longopt, shortopt, backend) \
- { longopt, shortopt, 0, NULL, NULL, setaction, 0, (void *)backend, (void_func *)execbackend }
+ { longopt, shortopt, 0, NULL, NULL, setaction, 0, (void *)backend, execbackend }
 
   ACTION( "install",                        'i', act_install,              archivefiles    ),
   ACTION( "unpack",                          0,  act_unpack,               archivefiles    ),
@@ -637,7 +637,7 @@ commandfd(const char *const *argv)
   int ret = 0;
   int c, lno, i;
   bool skipchar;
-  int (*actionfunction)(const char *const *argv);
+  action_func *actionfunction;
 
   pipein = *argv++;
   if (pipein == NULL)
@@ -719,7 +719,7 @@ commandfd(const char *const *argv)
     myopt((const char *const**)&newargs,cmdinfos);
     if (!cipaction) badusage(_("need an action option"));
 
-    actionfunction = (int (*)(const char *const *))cipaction->arg_func;
+    actionfunction = cipaction->arg_func;
     ret |= actionfunction(newargs);
 
     pop_error_context(ehflag_normaltidy);
@@ -729,7 +729,7 @@ commandfd(const char *const *argv)
 }
 
 int main(int argc, const char *const *argv) {
-  int (*actionfunction)(const char *const *argv);
+  action_func *actionfunction;
   int ret;
 
   setlocale(LC_ALL, "");
@@ -760,7 +760,7 @@ int main(int argc, const char *const *argv) {
 
   filesdbinit();
 
-  actionfunction = (int (*)(const char *const *))cipaction->arg_func;
+  actionfunction = cipaction->arg_func;
 
   ret = actionfunction(argv);
 

+ 2 - 2
src/querycmd.c

@@ -677,7 +677,7 @@ static const struct cmdinfo cmdinfos[]= {
 };
 
 int main(int argc, const char *const *argv) {
-  int (*actionfunction)(const char *const *argv);
+  action_func *actionfunction;
   int ret;
 
   setlocale(LC_ALL, "");
@@ -694,7 +694,7 @@ int main(int argc, const char *const *argv) {
   setvbuf(stdout, NULL, _IONBF, 0);
   filesdbinit();
 
-  actionfunction = (int (*)(const char *const *))cipaction->arg_func;
+  actionfunction = cipaction->arg_func;
 
   ret = actionfunction(argv);
 

+ 2 - 2
src/statcmd.c

@@ -362,7 +362,7 @@ static const struct cmdinfo cmdinfos[] = {
 int
 main(int argc, const char *const *argv)
 {
-	int (*actionfunction)(const char *const *argv);
+	action_func *actionfunction;
 	int ret;
 
 	setlocale(LC_ALL, "");
@@ -382,7 +382,7 @@ main(int argc, const char *const *argv)
 	filesdbinit();
 	ensure_statoverrides();
 
-	actionfunction = (int (*)(const char *const *))cipaction->arg_func;
+	actionfunction = cipaction->arg_func;
 	ret = actionfunction(argv);
 
 	standard_shutdown();