Explorar o código

Rename struct cmdinfo member arg_func to action and call it directly

This avoids a temporary variable, given that now the function is
strongly prototyped.
Guillem Jover %!s(int64=15) %!d(string=hai) anos
pai
achega
bfb43e8aae
Modificáronse 7 ficheiros con 11 adicións e 25 borrados
  1. 2 3
      dpkg-deb/main.c
  2. 2 3
      dpkg-split/main.c
  3. 2 1
      lib/dpkg/myopt.h
  4. 1 4
      src/divertcmd.c
  5. 2 7
      src/main.c
  6. 1 4
      src/querycmd.c
  7. 1 3
      src/statcmd.c

+ 2 - 3
dpkg-deb/main.c

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

+ 2 - 3
dpkg-split/main.c

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

+ 2 - 1
lib/dpkg/myopt.h

@@ -44,7 +44,8 @@ struct cmdinfo {
 
   int arg_int;
   void *arg_ptr;
-  action_func *arg_func;
+
+  action_func *action;
 };
 
 extern const char printforhelp[];

+ 1 - 4
src/divertcmd.c

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

+ 2 - 7
src/main.c

@@ -637,7 +637,6 @@ commandfd(const char *const *argv)
   int ret = 0;
   int c, lno, i;
   bool skipchar;
-  action_func *actionfunction;
 
   pipein = *argv++;
   if (pipein == NULL)
@@ -719,8 +718,7 @@ commandfd(const char *const *argv)
     myopt((const char *const**)&newargs,cmdinfos);
     if (!cipaction) badusage(_("need an action option"));
 
-    actionfunction = cipaction->arg_func;
-    ret |= actionfunction(newargs);
+    ret |= cipaction->action(newargs);
 
     pop_error_context(ehflag_normaltidy);
   }
@@ -729,7 +727,6 @@ commandfd(const char *const *argv)
 }
 
 int main(int argc, const char *const *argv) {
-  action_func *actionfunction;
   int ret;
 
   setlocale(LC_ALL, "");
@@ -760,9 +757,7 @@ int main(int argc, const char *const *argv) {
 
   filesdbinit();
 
-  actionfunction = cipaction->arg_func;
-
-  ret = actionfunction(argv);
+  ret = cipaction->action(argv);
 
   if (is_invoke_action(cipaction->arg_int))
     run_invoke_hooks(cipaction->olong, post_invoke_hooks);

+ 1 - 4
src/querycmd.c

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

+ 1 - 3
src/statcmd.c

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