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>
This commit is contained in:
parent
a3dcee3e8a
commit
16635cc2e0
@ -51,39 +51,49 @@
|
|||||||
|
|
||||||
enum token {
|
enum token {
|
||||||
EOI,
|
EOI,
|
||||||
FILRD,
|
|
||||||
|
FILRD, /* file access */
|
||||||
FILWR,
|
FILWR,
|
||||||
FILEX,
|
FILEX,
|
||||||
|
|
||||||
FILEXIST,
|
FILEXIST,
|
||||||
FILREG,
|
|
||||||
|
FILREG, /* file type */
|
||||||
FILDIR,
|
FILDIR,
|
||||||
FILCDEV,
|
FILCDEV,
|
||||||
FILBDEV,
|
FILBDEV,
|
||||||
FILFIFO,
|
FILFIFO,
|
||||||
FILSOCK,
|
FILSOCK,
|
||||||
|
|
||||||
FILSYM,
|
FILSYM,
|
||||||
FILGZ,
|
FILGZ,
|
||||||
FILTT,
|
FILTT,
|
||||||
FILSUID,
|
|
||||||
|
FILSUID, /* file bit */
|
||||||
FILSGID,
|
FILSGID,
|
||||||
FILSTCK,
|
FILSTCK,
|
||||||
FILNT,
|
|
||||||
|
FILNT, /* file ops */
|
||||||
FILOT,
|
FILOT,
|
||||||
FILEQ,
|
FILEQ,
|
||||||
|
|
||||||
FILUID,
|
FILUID,
|
||||||
FILGID,
|
FILGID,
|
||||||
STREZ,
|
|
||||||
|
STREZ, /* str ops */
|
||||||
STRNZ,
|
STRNZ,
|
||||||
STREQ,
|
STREQ,
|
||||||
STRNE,
|
STRNE,
|
||||||
STRLT,
|
STRLT,
|
||||||
STRGT,
|
STRGT,
|
||||||
INTEQ,
|
|
||||||
|
INTEQ, /* int ops */
|
||||||
INTNE,
|
INTNE,
|
||||||
INTGE,
|
INTGE,
|
||||||
INTGT,
|
INTGT,
|
||||||
INTLE,
|
INTLE,
|
||||||
INTLT,
|
INTLT,
|
||||||
|
|
||||||
UNOT,
|
UNOT,
|
||||||
BAND,
|
BAND,
|
||||||
BOR,
|
BOR,
|
||||||
@ -385,8 +395,8 @@ static int binop(void)
|
|||||||
return val1 > val2;
|
return val1 > val2;
|
||||||
if (op->op_num == INTLE)
|
if (op->op_num == INTLE)
|
||||||
return val1 <= val2;
|
return val1 <= val2;
|
||||||
if (op->op_num == INTLT)
|
/*if (op->op_num == INTLT)*/
|
||||||
return val1 < val2;
|
return val1 < val2;
|
||||||
}
|
}
|
||||||
if (is_str_op(op->op_num)) {
|
if (is_str_op(op->op_num)) {
|
||||||
val1 = strcmp(opnd1, opnd2);
|
val1 = strcmp(opnd1, opnd2);
|
||||||
@ -396,8 +406,8 @@ static int binop(void)
|
|||||||
return val1 != 0;
|
return val1 != 0;
|
||||||
if (op->op_num == STRLT)
|
if (op->op_num == STRLT)
|
||||||
return val1 < 0;
|
return val1 < 0;
|
||||||
if (op->op_num == STRGT)
|
/*if (op->op_num == STRGT)*/
|
||||||
return val1 > 0;
|
return val1 > 0;
|
||||||
}
|
}
|
||||||
/* We are sure that these three are by now the only binops we didn't check
|
/* We are sure that these three are by now the only binops we didn't check
|
||||||
* yet, so we do not check if the class is correct:
|
* yet, so we do not check if the class is correct:
|
||||||
@ -412,25 +422,29 @@ static int binop(void)
|
|||||||
return b1.st_mtime > b2.st_mtime;
|
return b1.st_mtime > b2.st_mtime;
|
||||||
if (op->op_num == FILOT)
|
if (op->op_num == FILOT)
|
||||||
return b1.st_mtime < b2.st_mtime;
|
return b1.st_mtime < b2.st_mtime;
|
||||||
if (op->op_num == FILEQ)
|
/*if (op->op_num == FILEQ)*/
|
||||||
return b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino;
|
return b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino;
|
||||||
}
|
}
|
||||||
return 1; /* NOTREACHED */
|
/*return 1; - NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void initialize_group_array(void)
|
static void initialize_group_array(void)
|
||||||
{
|
{
|
||||||
ngroups = getgroups(0, NULL);
|
int n;
|
||||||
if (ngroups > 0) {
|
|
||||||
|
/* getgroups may be expensive, try to use it only once */
|
||||||
|
ngroups = 32;
|
||||||
|
do {
|
||||||
/* FIXME: ash tries so hard to not die on OOM,
|
/* FIXME: ash tries so hard to not die on OOM,
|
||||||
* and we spoil it with just one xrealloc here */
|
* and we spoil it with just one xrealloc here */
|
||||||
/* We realloc, because test_main can be entered repeatedly by shell.
|
/* We realloc, because test_main can be entered repeatedly by shell.
|
||||||
* Testcase (ash): 'while true; do test -x some_file; done'
|
* Testcase (ash): 'while true; do test -x some_file; done'
|
||||||
* and watch top. (some_file must have owner != you) */
|
* and watch top. (some_file must have owner != you) */
|
||||||
group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
|
n = ngroups;
|
||||||
getgroups(ngroups, group_array);
|
group_array = xrealloc(group_array, n * sizeof(gid_t));
|
||||||
}
|
ngroups = getgroups(n, group_array);
|
||||||
|
} while (ngroups > n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -717,7 +731,7 @@ int test_main(int argc, char **argv)
|
|||||||
* isn't likely in the case of a shell. paranoia
|
* isn't likely in the case of a shell. paranoia
|
||||||
* prevails...
|
* prevails...
|
||||||
*/
|
*/
|
||||||
ngroups = 0;
|
/*ngroups = 0; - done by INIT_S() */
|
||||||
|
|
||||||
//argc--;
|
//argc--;
|
||||||
argv++;
|
argv++;
|
||||||
|
@ -276,10 +276,12 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
setsockopt_reuseaddr(sock);
|
setsockopt_reuseaddr(sock);
|
||||||
sa_len = lsa->len; /* I presume sockaddr len stays the same */
|
sa_len = lsa->len; /* I presume sockaddr len stays the same */
|
||||||
xbind(sock, &lsa->u.sa, sa_len);
|
xbind(sock, &lsa->u.sa, sa_len);
|
||||||
if (tcp)
|
if (tcp) {
|
||||||
xlisten(sock, backlog);
|
xlisten(sock, backlog);
|
||||||
else /* udp: needed for recv_from_to to work: */
|
close_on_exec_on(sock);
|
||||||
|
} else { /* udp: needed for recv_from_to to work: */
|
||||||
socket_want_pktinfo(sock);
|
socket_want_pktinfo(sock);
|
||||||
|
}
|
||||||
/* ndelay_off(sock); - it is the default I think? */
|
/* ndelay_off(sock); - it is the default I think? */
|
||||||
|
|
||||||
#ifndef SSLSVD
|
#ifndef SSLSVD
|
||||||
@ -410,10 +412,6 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
/* Child: prepare env, log, and exec prog */
|
/* Child: prepare env, log, and exec prog */
|
||||||
|
|
||||||
/* Closing tcp listening socket */
|
|
||||||
if (tcp)
|
|
||||||
close(sock);
|
|
||||||
|
|
||||||
{ /* vfork alert! every xmalloc in this block should be freed! */
|
{ /* vfork alert! every xmalloc in this block should be freed! */
|
||||||
char *local_hostname = local_hostname; /* for compiler */
|
char *local_hostname = local_hostname; /* for compiler */
|
||||||
char *local_addr = NULL;
|
char *local_addr = NULL;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# you can just add an entry like:
|
# you can just add an entry like:
|
||||||
# /sbin/foobar f 2755 0 0 - - - - -
|
# /sbin/foobar f 2755 0 0 - - - - -
|
||||||
# and (assuming the file /sbin/foobar exists) it will be made setuid
|
# and (assuming the file /sbin/foobar exists) it will be made setuid
|
||||||
# root (regardless of what its permissions are on the host filesystem.
|
# root (regardless of what its permissions are on the host filesystem).
|
||||||
# Furthermore, you can use a single table entry to create a many device
|
# Furthermore, you can use a single table entry to create a many device
|
||||||
# minors. For example, if I wanted to create /dev/hda and /dev/hda[0-15]
|
# minors. For example, if I wanted to create /dev/hda and /dev/hda[0-15]
|
||||||
# I could just use the following two table entries:
|
# I could just use the following two table entries:
|
||||||
|
Loading…
Reference in New Issue
Block a user