Explorar el Código

libdpkg: Rename sizeof_array to array_count

The new name makes more sense, as the former might seem to imply the
total size of the array and not the amount of elements in it.
Guillem Jover hace 16 años
padre
commit
675f12250e
Se han modificado 7 ficheros con 11 adiciones y 11 borrados
  1. 1 1
      dpkg-deb/main.c
  2. 1 1
      dpkg-split/main.c
  3. 1 1
      lib/dpkg/ehandle.c
  4. 2 2
      lib/dpkg/macros.h
  5. 2 2
      lib/dpkg/parse.c
  6. 3 3
      lib/dpkg/subproc.c
  7. 1 1
      utils/start-stop-daemon.c

+ 1 - 1
dpkg-deb/main.c

@@ -188,7 +188,7 @@ static void setaction(const struct cmdinfo *cip, const char *value) {
     badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"),
     badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"),
              cip->oshort, cip->olong, cipaction->oshort, cipaction->olong);
              cip->oshort, cip->olong, cipaction->oshort, cipaction->olong);
   cipaction= cip;
   cipaction= cip;
-  assert((int)(cip - cmdinfos) < (int)(sizeof_array(dofunctions)));
+  assert((int)(cip - cmdinfos) < (int)(array_count(dofunctions)));
   action= dofunctions[cip-cmdinfos];
   action= dofunctions[cip-cmdinfos];
 }
 }
 
 

+ 1 - 1
dpkg-split/main.c

@@ -168,7 +168,7 @@ static void setaction(const struct cmdinfo *cip, const char *value) {
     badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"),
     badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"),
              cip->oshort, cip->olong, cipaction->oshort, cipaction->olong);
              cip->oshort, cip->olong, cipaction->oshort, cipaction->olong);
   cipaction= cip;
   cipaction= cip;
-  assert((int)(cip - cmdinfos) < (int)(sizeof_array(dofunctions)));
+  assert((int)(cip - cmdinfos) < (int)(array_count(dofunctions)));
   action= dofunctions[cip-cmdinfos];
   action= dofunctions[cip-cmdinfos];
 }
 }
 
 

+ 1 - 1
lib/dpkg/ehandle.c

@@ -209,7 +209,7 @@ void push_cleanup(void (*call1)(int argc, void **argv), int mask1,
   
   
   cep= malloc(sizeof(struct cleanupentry) + sizeof(char*)*(nargs+1));
   cep= malloc(sizeof(struct cleanupentry) + sizeof(char*)*(nargs+1));
   if (!cep) {
   if (!cep) {
-    if (nargs > sizeof_array(emergency.args))
+    if (nargs > array_count(emergency.args))
       ohshite(_("out of memory for new cleanup entry with many arguments"));
       ohshite(_("out of memory for new cleanup entry with many arguments"));
     e= errno; cep= &emergency.ce;
     e= errno; cep= &emergency.ce;
   }
   }

+ 2 - 2
lib/dpkg/macros.h

@@ -45,8 +45,8 @@
 #define DPKG_END_DECLS
 #define DPKG_END_DECLS
 #endif
 #endif
 
 
-#ifndef sizeof_array
-#define sizeof_array(a) (sizeof(a) / sizeof((a)[0]))
+#ifndef array_count
+#define array_count(a) (sizeof(a) / sizeof((a)[0]))
 #endif
 #endif
 
 
 #ifndef min
 #ifndef min

+ 2 - 2
lib/dpkg/parse.c

@@ -80,7 +80,7 @@ const struct fieldinfo fieldinfos[]= {
   {  NULL   /* sentinel - tells code that list is ended */                               }
   {  NULL   /* sentinel - tells code that list is ended */                               }
 };
 };
 
 
-const int nfields = sizeof_array(fieldinfos);
+const int nfields = array_count(fieldinfos);
 
 
 int parsedb(const char *filename, enum parsedbflags flags,
 int parsedb(const char *filename, enum parsedbflags flags,
             struct pkginfo **donep, FILE *warnto, int *warncount) {
             struct pkginfo **donep, FILE *warnto, int *warncount) {
@@ -94,7 +94,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
   struct arbitraryfield *arp, **larpp;
   struct arbitraryfield *arp, **larpp;
   struct trigaw *ta;
   struct trigaw *ta;
   int pdone;
   int pdone;
-  int fieldencountered[sizeof_array(fieldinfos)];
+  int fieldencountered[array_count(fieldinfos)];
   const struct fieldinfo *fip;
   const struct fieldinfo *fip;
   const struct nickname *nick;
   const struct nickname *nick;
   char *data, *dataptr, *endptr;
   char *data, *dataptr, *endptr;

+ 3 - 3
lib/dpkg/subproc.c

@@ -36,7 +36,7 @@
 #include <dpkg/subproc.h>
 #include <dpkg/subproc.h>
 
 
 static int catch_signals[] = { SIGQUIT, SIGINT };
 static int catch_signals[] = { SIGQUIT, SIGINT };
-static struct sigaction uncatch_signals[sizeof_array(catch_signals)];
+static struct sigaction uncatch_signals[array_count(catch_signals)];
 
 
 void
 void
 subproc_signals_setup(const char *name)
 subproc_signals_setup(const char *name)
@@ -49,7 +49,7 @@ subproc_signals_setup(const char *name)
 	catchsig.sa_handler = SIG_IGN;
 	catchsig.sa_handler = SIG_IGN;
 	sigemptyset(&catchsig.sa_mask);
 	sigemptyset(&catchsig.sa_mask);
 	catchsig.sa_flags = 0;
 	catchsig.sa_flags = 0;
-	for (i = 0; i < sizeof_array(catch_signals); i++)
+	for (i = 0; i < array_count(catch_signals); i++)
 		if (sigaction(catch_signals[i], &catchsig, &uncatch_signals[i]))
 		if (sigaction(catch_signals[i], &catchsig, &uncatch_signals[i]))
 			ohshite(_("unable to ignore signal %s before running %.250s"),
 			ohshite(_("unable to ignore signal %s before running %.250s"),
 			        strsignal(catch_signals[i]), name);
 			        strsignal(catch_signals[i]), name);
@@ -62,7 +62,7 @@ subproc_signals_cleanup(int argc, void **argv)
 {
 {
 	size_t i;
 	size_t i;
 
 
-	for (i = 0; i < sizeof_array(catch_signals); i++) {
+	for (i = 0; i < array_count(catch_signals); i++) {
 		if (sigaction(catch_signals[i], &uncatch_signals[i], NULL)) {
 		if (sigaction(catch_signals[i], &uncatch_signals[i], NULL)) {
 			fprintf(stderr, _("error un-catching signal %s: %s\n"),
 			fprintf(stderr, _("error un-catching signal %s: %s\n"),
 			        strsignal(catch_signals[i]), strerror(errno));
 			        strsignal(catch_signals[i]), strerror(errno));

+ 1 - 1
utils/start-stop-daemon.c

@@ -482,7 +482,7 @@ parse_signal(const char *signal_str, int *signal_nr)
 	if (parse_integer(signal_str, signal_nr) == 0)
 	if (parse_integer(signal_str, signal_nr) == 0)
 		return 0;
 		return 0;
 
 
-	for (i = 0; i < sizeof_array(siglist); i++) {
+	for (i = 0; i < array_count(siglist); i++) {
 		if (strcmp(signal_str, siglist[i].name) == 0) {
 		if (strcmp(signal_str, siglist[i].name) == 0) {
 			*signal_nr = siglist[i].signal;
 			*signal_nr = siglist[i].signal;
 			return 0;
 			return 0;