From owner-freebsd-bugs@FreeBSD.ORG Mon Dec 3 04:30:01 2012 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EBD89A1D for ; Mon, 3 Dec 2012 04:30:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id C0E1E8FC15 for ; Mon, 3 Dec 2012 04:30:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id qB34U06b000879 for ; Mon, 3 Dec 2012 04:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id qB34U0EF000867; Mon, 3 Dec 2012 04:30:00 GMT (envelope-from gnats) Resent-Date: Mon, 3 Dec 2012 04:30:00 GMT Resent-Message-Id: <201212030430.qB34U0EF000867@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Garrett Cooper Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F1AA2747 for ; Mon, 3 Dec 2012 04:21:09 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id BFF4D8FC0C for ; Mon, 3 Dec 2012 04:21:09 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id qB34L9gx043942 for ; Mon, 3 Dec 2012 04:21:09 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id qB34L95Z043932; Mon, 3 Dec 2012 04:21:09 GMT (envelope-from nobody) Message-Id: <201212030421.qB34L95Z043932@red.freebsd.org> Date: Mon, 3 Dec 2012 04:21:09 GMT From: Garrett Cooper To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: bin/174073: [patch] style(9) fixes for xargs(1) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Dec 2012 04:30:01 -0000 >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: