Date: Mon, 3 Dec 2012 04:21:09 GMT From: Garrett Cooper <yanegomi@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/174073: [patch] style(9) fixes for xargs(1) Message-ID: <201212030421.qB34L95Z043932@red.freebsd.org> Resent-Message-ID: <201212030430.qB34U0EF000867@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 174073 >Category: bin >Synopsis: [patch] style(9) fixes for xargs(1) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Dec 03 04:30:00 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Garrett Cooper >Release: n/a >Organization: EMC Isilon >Environment: n/a >Description: The attached patch consists of style(9) fixes for xargs(1) that I submitted to mckay@ and he acked, but weren't committed. >How-To-Repeat: >Fix: Patch attached with submission follows: Index: usr.bin/xargs/xargs.c =================================================================== --- usr.bin/xargs/xargs.c (revision 243802) +++ usr.bin/xargs/xargs.c (working copy) @@ -98,8 +98,8 @@ main(int argc, char *argv[]) { long arg_max; + size_t linelen; int ch, Jflag, nargs, nflag, nline; - size_t linelen; char *endptr; inpline = replstr = NULL; @@ -126,10 +126,9 @@ if ((arg_max = sysconf(_SC_ARG_MAX)) == -1) errx(1, "sysconf(_SC_ARG_MAX) failed"); nline = arg_max - 4 * 1024; - while (*ep != NULL) { + while (*ep != NULL) /* 1 byte for each '\0' */ - nline -= strlen(*ep++) + 1 + sizeof(*ep); - } + nline -= strlen(*ep++) + 1 + sizeof(*ep); maxprocs = 1; while ((ch = getopt(argc, argv, "0E:I:J:L:n:oP:pR:S:s:rtx")) != -1) switch (ch) { @@ -524,9 +523,9 @@ static void run(char **argv) { + char **avec; pid_t pid; int fd; - char **avec; /* * If the user wants to be notified of each command before it is @@ -568,9 +567,8 @@ if (oflag) { if ((fd = open(_PATH_TTY, O_RDONLY)) == -1) err(1, "can't open /dev/tty"); - } else { + } else fd = open(_PATH_DEVNULL, O_RDONLY); - } if (fd > STDIN_FILENO) { if (dup2(fd, STDIN_FILENO) != 0) err(1, "can't dup2 to stdin"); @@ -593,7 +591,8 @@ * If block is not set and no children have exited, returns 0 immediately. */ static pid_t -xwait(int block, int *status) { +xwait(int block, int *status) +{ pid_t pid; if (pids_empty()) { @@ -670,12 +669,14 @@ static int pids_empty(void) { + return (curprocs == 0); } static int pids_full(void) { + return (curprocs >= maxprocs); } @@ -709,7 +710,6 @@ if ((slot = findslot(NOPID)) < 0) errx(1, "internal error: no free pid slot"); - return (slot); } @@ -721,13 +721,13 @@ for (slot = 0; slot < maxprocs; slot++) if (childpids[slot] == pid) return (slot); - return (-1); } static void clearslot(int slot) { + childpids[slot] = NOPID; } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212030421.qB34L95Z043932>