From owner-freebsd-hackers@freebsd.org Mon May 13 06:40:04 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 849B115AD57B for ; Mon, 13 May 2019 06:40:04 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from dedi548.your-server.de (dedi548.your-server.de [IPv6:2a01:4f8:d0a:2645::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D3DD76B2A3 for ; Mon, 13 May 2019 06:40:02 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from [88.198.220.132] (helo=sslproxy03.your-server.de) by dedi548.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1hQ4cr-00079M-5U for freebsd-hackers@freebsd.org; Mon, 13 May 2019 08:39:53 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy03.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hQ4cq-0007vR-TG for freebsd-hackers@freebsd.org; Mon, 13 May 2019 08:39:52 +0200 Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 0C58F2A165B for ; Mon, 13 May 2019 08:40:23 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id S72q9-5NX-pM for ; Mon, 13 May 2019 08:40:22 +0200 (CEST) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id C67292A165C for ; Mon, 13 May 2019 08:40:22 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id vA8WEI7bgz77 for ; Mon, 13 May 2019 08:40:22 +0200 (CEST) Received: from linux-diu0.suse (unknown [192.168.96.161]) by mail.embedded-brains.de (Postfix) with ESMTP id A55B92A165B for ; Mon, 13 May 2019 08:40:22 +0200 (CEST) From: Sebastian Huber To: freebsd-hackers@freebsd.org Subject: [PATCH] ifconfig: Avoid superfluous write to const string Date: Mon, 13 May 2019 08:39:51 +0200 Message-Id: <20190513063951.6521-1-sebastian.huber@embedded-brains.de> X-Mailer: git-send-email 2.16.4 X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.100.3/25447/Sun May 12 09:56:54 2019) X-Rspamd-Queue-Id: D3DD76B2A3 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; spf=softfail (mx1.freebsd.org: 2a01:4f8:d0a:2645::2 is neither permitted nor denied by domain of sebastian.huber@embedded-brains.de) smtp.mailfrom=sebastian.huber@embedded-brains.de X-Spamd-Result: default: False [-2.73 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; R_SPF_SOFTFAIL(0.00)[~all]; RCPT_COUNT_ONE(0.00)[1]; RCVD_TLS_LAST(0.00)[]; MX_GOOD(-0.01)[mx.embeddedbrains.de,mx.netmuc.net]; NEURAL_HAM_SHORT(-0.86)[-0.863,0]; MID_CONTAINS_FROM(1.00)[]; IP_SCORE(-0.76)[ipnet: 2a01:4f8::/29(-2.05), asn: 24940(-1.74), country: DE(-0.01)]; DMARC_NA(0.00)[embedded-brains.de]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/29, country:DE]; RCVD_COUNT_SEVEN(0.00)[8]; HAS_X_AS(0.00)[] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 May 2019 06:40:04 -0000 --- sbin/ifconfig/af_inet.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sbin/ifconfig/af_inet.c b/sbin/ifconfig/af_inet.c index 3d44a4c0b99..279a31773f4 100644 --- a/sbin/ifconfig/af_inet.c +++ b/sbin/ifconfig/af_inet.c @@ -141,20 +141,18 @@ in_getaddr(const char *s, int which) sin->sin_family = AF_INET; if (which == ADDR) { - char *p = NULL; + const char *p = strrchr(s, '/'); - if((p = strrchr(s, '/')) != NULL) { + if (p != NULL) { const char *errstr; /* address is `name/masklen' */ int masklen; struct sockaddr_in *min = sintab[MASK]; - *p = '\0'; if (!isdigit(*(p + 1))) errstr = "invalid"; else masklen = (int)strtonum(p + 1, 0, 32, &errstr); if (errstr != NULL) { - *p = '/'; errx(1, "%s: bad value (width %s)", s, errstr); } min->sin_family = AF_INET; -- 2.16.4