Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Sep 2019 13:34:20 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r352212 - head/sbin/nvmecontrol
Message-ID:  <201909111334.x8BDYKNu071534@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Wed Sep 11 13:34:19 2019
New Revision: 352212
URL: https://svnweb.freebsd.org/changeset/base/352212

Log:
  Assume all the short args have optional args so allocate space for the
  ':'. It's slightly wasteful, but much easier (and the savings in bytes
  at runtime would be tiny, but the code to do it larger).
  
  Submitted by: Sebastian Huber

Modified:
  head/sbin/nvmecontrol/comnd.c

Modified: head/sbin/nvmecontrol/comnd.c
==============================================================================
--- head/sbin/nvmecontrol/comnd.c	Wed Sep 11 13:27:10 2019	(r352211)
+++ head/sbin/nvmecontrol/comnd.c	Wed Sep 11 13:34:19 2019	(r352212)
@@ -189,7 +189,7 @@ arg_parse(int argc, char * const * argv, const struct 
 	lopts = malloc((n + 2) * sizeof(struct option));
 	if (lopts == NULL)
 		err(1, "option memory");
-	p = shortopts = malloc((n + 3) * sizeof(char));
+	p = shortopts = malloc((2 * n + 3) * sizeof(char));
 	if (shortopts == NULL)
 		err(1, "shortopts memory");
 	idx = 0;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909111334.x8BDYKNu071534>