From nobody Mon Jun 05 18:51:23 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QZjPS6y9zz4Ztx9; Mon, 5 Jun 2023 18:51:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QZjPS03nbz3s6Y; Mon, 5 Jun 2023 18:51:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685991084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Xfcrzt4vTDMYyS5wU5xTemGkbRkxlmAkb9QKI+D/gOg=; b=ua1OeRsMJlZX/bIpukjJaAWDAWYbpurDiAnfmOFqUc7SFdM8YyEIWwmz10fFR/83TMVANX n8OuVcHQq+odwut0Aaf80HB15uq5NT6ya3egdGGtHY8pt8uIT+0wHtBiquP0/2xAbTQ1c4 DyLeUiWclzjS5Mt3I2LLbIoSzfm3BoLM0DYNl+xhY/VQ8/gujhS2fxOA8xxh7hUelRXyKh g0BHA/reP0srPdlyQajvIomo8WpurZPLzXyf2jqqa5psD8dEoBXDmykxcWbCH3uV4VzEtZ mTgll75wwkcMcR2Sg3RMYVvX/obNNXRbF7XUWIxk7GhLfFr7oAQKjWy6+2Uk6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685991084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Xfcrzt4vTDMYyS5wU5xTemGkbRkxlmAkb9QKI+D/gOg=; b=pThF2TkHBQDCjlQ0qAEbLxSFYBC3OkUulY1SluEnlHR0Canzg5V5enNgwLBOVxjDv9R4f2 8iaW2oHXImRM1od/41xU31ahD0Am23NugLL11kfnAUvrXavMkMsVRy5S9bZX1VKchzQ+IC 8di1OEoREJmfnGrkThwLxILmJ26iFN34zvOXyFz00V2l8tJC3CKgf10Z9rHZB5r5uTwT1J L3aUydcxm/uc0trMDhyiQD1GdLTINgO2T9MF/QccJjhVyAtBTS1E5yJKg1FbX77SR78VO4 F9ynMxW3o1LEDS4bOiDsDjR/lrTsLKCoo7gQ1FgDy0uHNszakCUmpe/Yn+UjfQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685991084; a=rsa-sha256; cv=none; b=HQLS48b8lBw/LbbCOdUYldNzXPTKR54pySqrf7tXEHIrQAmkbfxOmRPmblMlD7iI2LeIkb 05watJGjPU30p1hetyHj3++V1tRQ7SC88MM01IsBeiX3F8qPh88yoZYKONjt9B5/wIbVa8 2Y72AdCKOBvejEmTIOjNXbhV+zZrr/Fxhb+3z0zT5sqfblYJwQFg1NNx2uzpEtxnBiNwyK CyMXi+yuJVl8DuuLWJUOogwyA7a3t5QlTuHkog9ve2SpDB7wuUpaeMd68DYo4kmnObO9x2 F9kmkbkAFdlZcD9I7hbnfjHY5kyCmrdx0V7cbUYADXJOxiq6VpqSsBJSyTqLaA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QZjPR6Gm4zyPg; Mon, 5 Jun 2023 18:51:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 355IpNt1048730; Mon, 5 Jun 2023 18:51:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 355IpNIV048729; Mon, 5 Jun 2023 18:51:23 GMT (envelope-from git) Date: Mon, 5 Jun 2023 18:51:23 GMT Message-Id: <202306051851.355IpNIV048729@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= Subject: git: fbc445addf91 - main - xargs: Consistently use strtonum() to parse arguments. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fbc445addf9183d180bb8b488281617bb19d9242 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=fbc445addf9183d180bb8b488281617bb19d9242 commit fbc445addf9183d180bb8b488281617bb19d9242 Author: Dag-Erling Smørgrav AuthorDate: 2023-06-05 18:50:54 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2023-06-05 18:50:54 +0000 xargs: Consistently use strtonum() to parse arguments. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D40425 --- usr.bin/xargs/xargs.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index eb496d8e09fe..e832cbb35a31 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -124,7 +124,6 @@ main(int argc, char *argv[]) int ch, Jflag, nargs, nflag, nline; size_t linelen; struct rlimit rl; - char *endptr; const char *errstr; inpline = replstr = NULL; @@ -175,23 +174,23 @@ main(int argc, char *argv[]) replstr = optarg; break; case 'L': - Lflag = strtonum(optarg, 0, INT_MAX, &errstr); + Lflag = (int)strtonum(optarg, 0, INT_MAX, &errstr); if (errstr) - errx(1, "-L %s: %s", optarg, errstr); + errx(1, "-%c %s: %s", ch, optarg, errstr); break; case 'n': nflag = 1; - nargs = strtonum(optarg, 1, INT_MAX, &errstr); + nargs = (int)strtonum(optarg, 1, INT_MAX, &errstr); if (errstr) - errx(1, "-n %s: %s", optarg, errstr); + errx(1, "-%c %s: %s", ch, optarg, errstr); break; case 'o': oflag = 1; break; case 'P': - maxprocs = strtonum(optarg, 0, INT_MAX, &errstr); + maxprocs = (int)strtonum(optarg, 0, INT_MAX, &errstr); if (errstr) - errx(1, "-P %s: %s", optarg, errstr); + errx(1, "-%c %s: %s", ch, optarg, errstr); if (getrlimit(RLIMIT_NPROC, &rl) != 0) errx(1, "getrlimit failed"); if (maxprocs == 0 || maxprocs > rl.rlim_cur) @@ -201,22 +200,22 @@ main(int argc, char *argv[]) pflag = 1; break; case 'R': - Rflag = strtol(optarg, &endptr, 10); - if (*endptr != '\0') - errx(1, "replacements must be a number"); + Rflag = (int)strtonum(optarg, 0, INT_MAX, &errstr); + if (errstr) + errx(1, "-%c %s: %s", ch, optarg, errstr); break; case 'r': /* GNU compatibility */ break; case 'S': - Sflag = strtoul(optarg, &endptr, 10); - if (*endptr != '\0') - errx(1, "replsize must be a number"); + Sflag = (int)strtonum(optarg, 0, INT_MAX, &errstr); + if (errstr) + errx(1, "-%c %s: %s", ch, optarg, errstr); break; case 's': - nline = strtonum(optarg, 0, INT_MAX, &errstr); + nline = (int)strtonum(optarg, 0, INT_MAX, &errstr); if (errstr) - errx(1, "-s %s: %s", optarg, errstr); + errx(1, "-%c %s: %s", ch, optarg, errstr); break; case 't': tflag = 1;