aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-06-13 22:49:08 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-06-13 22:49:08 +0200
commit16635cc2e052897ce7c2d4989acd0b706c3ac3dd (patch)
tree35af25c96f7f6e6340c043a91b10f46593c6afce
parenta3dcee3e8a2d41e90cc235fd407dff9fe99d8604 (diff)
downloadbusybox-w32-16635cc2e052897ce7c2d4989acd0b706c3ac3dd.tar.gz
busybox-w32-16635cc2e052897ce7c2d4989acd0b706c3ac3dd.tar.bz2
busybox-w32-16635cc2e052897ce7c2d4989acd0b706c3ac3dd.zip
test, tcpsvd, tcpsvd: shrink
function old new delta nexpr 825 826 +1 tcpudpsvd_main 1830 1822 -8 test_main 257 247 -10 binop 584 525 -59 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 1/-77) Total: -76 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/test.c52
-rw-r--r--networking/tcpudp.c10
-rw-r--r--testsuite/makedevs.device_table.txt2
3 files changed, 38 insertions, 26 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index ae40192a2..cfaf4ca5d 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -51,39 +51,49 @@
51 51
52enum token { 52enum token {
53 EOI, 53 EOI,
54 FILRD, 54
55 FILRD, /* file access */
55 FILWR, 56 FILWR,
56 FILEX, 57 FILEX,
58
57 FILEXIST, 59 FILEXIST,
58 FILREG, 60
61 FILREG, /* file type */
59 FILDIR, 62 FILDIR,
60 FILCDEV, 63 FILCDEV,
61 FILBDEV, 64 FILBDEV,
62 FILFIFO, 65 FILFIFO,
63 FILSOCK, 66 FILSOCK,
67
64 FILSYM, 68 FILSYM,
65 FILGZ, 69 FILGZ,
66 FILTT, 70 FILTT,
67 FILSUID, 71
72 FILSUID, /* file bit */
68 FILSGID, 73 FILSGID,
69 FILSTCK, 74 FILSTCK,
70 FILNT, 75
76 FILNT, /* file ops */
71 FILOT, 77 FILOT,
72 FILEQ, 78 FILEQ,
79
73 FILUID, 80 FILUID,
74 FILGID, 81 FILGID,
75 STREZ, 82
83 STREZ, /* str ops */
76 STRNZ, 84 STRNZ,
77 STREQ, 85 STREQ,
78 STRNE, 86 STRNE,
79 STRLT, 87 STRLT,
80 STRGT, 88 STRGT,
81 INTEQ, 89
90 INTEQ, /* int ops */
82 INTNE, 91 INTNE,
83 INTGE, 92 INTGE,
84 INTGT, 93 INTGT,
85 INTLE, 94 INTLE,
86 INTLT, 95 INTLT,
96
87 UNOT, 97 UNOT,
88 BAND, 98 BAND,
89 BOR, 99 BOR,
@@ -385,8 +395,8 @@ static int binop(void)
385 return val1 > val2; 395 return val1 > val2;
386 if (op->op_num == INTLE) 396 if (op->op_num == INTLE)
387 return val1 <= val2; 397 return val1 <= val2;
388 if (op->op_num == INTLT) 398 /*if (op->op_num == INTLT)*/
389 return val1 < val2; 399 return val1 < val2;
390 } 400 }
391 if (is_str_op(op->op_num)) { 401 if (is_str_op(op->op_num)) {
392 val1 = strcmp(opnd1, opnd2); 402 val1 = strcmp(opnd1, opnd2);
@@ -396,8 +406,8 @@ static int binop(void)
396 return val1 != 0; 406 return val1 != 0;
397 if (op->op_num == STRLT) 407 if (op->op_num == STRLT)
398 return val1 < 0; 408 return val1 < 0;
399 if (op->op_num == STRGT) 409 /*if (op->op_num == STRGT)*/
400 return val1 > 0; 410 return val1 > 0;
401 } 411 }
402 /* We are sure that these three are by now the only binops we didn't check 412 /* We are sure that these three are by now the only binops we didn't check
403 * yet, so we do not check if the class is correct: 413 * yet, so we do not check if the class is correct:
@@ -412,25 +422,29 @@ static int binop(void)
412 return b1.st_mtime > b2.st_mtime; 422 return b1.st_mtime > b2.st_mtime;
413 if (op->op_num == FILOT) 423 if (op->op_num == FILOT)
414 return b1.st_mtime < b2.st_mtime; 424 return b1.st_mtime < b2.st_mtime;
415 if (op->op_num == FILEQ) 425 /*if (op->op_num == FILEQ)*/
416 return b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino; 426 return b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino;
417 } 427 }
418 return 1; /* NOTREACHED */ 428 /*return 1; - NOTREACHED */
419} 429}
420 430
421 431
422static void initialize_group_array(void) 432static void initialize_group_array(void)
423{ 433{
424 ngroups = getgroups(0, NULL); 434 int n;
425 if (ngroups > 0) { 435
436 /* getgroups may be expensive, try to use it only once */
437 ngroups = 32;
438 do {
426 /* FIXME: ash tries so hard to not die on OOM, 439 /* FIXME: ash tries so hard to not die on OOM,
427 * and we spoil it with just one xrealloc here */ 440 * and we spoil it with just one xrealloc here */
428 /* We realloc, because test_main can be entered repeatedly by shell. 441 /* We realloc, because test_main can be entered repeatedly by shell.
429 * Testcase (ash): 'while true; do test -x some_file; done' 442 * Testcase (ash): 'while true; do test -x some_file; done'
430 * and watch top. (some_file must have owner != you) */ 443 * and watch top. (some_file must have owner != you) */
431 group_array = xrealloc(group_array, ngroups * sizeof(gid_t)); 444 n = ngroups;
432 getgroups(ngroups, group_array); 445 group_array = xrealloc(group_array, n * sizeof(gid_t));
433 } 446 ngroups = getgroups(n, group_array);
447 } while (ngroups > n);
434} 448}
435 449
436 450
@@ -717,7 +731,7 @@ int test_main(int argc, char **argv)
717 * isn't likely in the case of a shell. paranoia 731 * isn't likely in the case of a shell. paranoia
718 * prevails... 732 * prevails...
719 */ 733 */
720 ngroups = 0; 734 /*ngroups = 0; - done by INIT_S() */
721 735
722 //argc--; 736 //argc--;
723 argv++; 737 argv++;
diff --git a/networking/tcpudp.c b/networking/tcpudp.c
index 55a3e0899..a5be192fb 100644
--- a/networking/tcpudp.c
+++ b/networking/tcpudp.c
@@ -276,10 +276,12 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
276 setsockopt_reuseaddr(sock); 276 setsockopt_reuseaddr(sock);
277 sa_len = lsa->len; /* I presume sockaddr len stays the same */ 277 sa_len = lsa->len; /* I presume sockaddr len stays the same */
278 xbind(sock, &lsa->u.sa, sa_len); 278 xbind(sock, &lsa->u.sa, sa_len);
279 if (tcp) 279 if (tcp) {
280 xlisten(sock, backlog); 280 xlisten(sock, backlog);
281 else /* udp: needed for recv_from_to to work: */ 281 close_on_exec_on(sock);
282 } else { /* udp: needed for recv_from_to to work: */
282 socket_want_pktinfo(sock); 283 socket_want_pktinfo(sock);
284 }
283 /* ndelay_off(sock); - it is the default I think? */ 285 /* ndelay_off(sock); - it is the default I think? */
284 286
285#ifndef SSLSVD 287#ifndef SSLSVD
@@ -410,10 +412,6 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
410 412
411 /* Child: prepare env, log, and exec prog */ 413 /* Child: prepare env, log, and exec prog */
412 414
413 /* Closing tcp listening socket */
414 if (tcp)
415 close(sock);
416
417 { /* vfork alert! every xmalloc in this block should be freed! */ 415 { /* vfork alert! every xmalloc in this block should be freed! */
418 char *local_hostname = local_hostname; /* for compiler */ 416 char *local_hostname = local_hostname; /* for compiler */
419 char *local_addr = NULL; 417 char *local_addr = NULL;
diff --git a/testsuite/makedevs.device_table.txt b/testsuite/makedevs.device_table.txt
index 4400083f8..88ac2092f 100644
--- a/testsuite/makedevs.device_table.txt
+++ b/testsuite/makedevs.device_table.txt
@@ -8,7 +8,7 @@
8# you can just add an entry like: 8# you can just add an entry like:
9# /sbin/foobar f 2755 0 0 - - - - - 9# /sbin/foobar f 2755 0 0 - - - - -
10# and (assuming the file /sbin/foobar exists) it will be made setuid 10# and (assuming the file /sbin/foobar exists) it will be made setuid
11# root (regardless of what its permissions are on the host filesystem. 11# root (regardless of what its permissions are on the host filesystem).
12# Furthermore, you can use a single table entry to create a many device 12# Furthermore, you can use a single table entry to create a many device
13# minors. For example, if I wanted to create /dev/hda and /dev/hda[0-15] 13# minors. For example, if I wanted to create /dev/hda and /dev/hda[0-15]
14# I could just use the following two table entries: 14# I could just use the following two table entries: