Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Nov 2014 10:45:56 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r275186 - stable/10/usr.sbin/ctld
Message-ID:  <201411271045.sARAjuo6056714@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Thu Nov 27 10:45:55 2014
New Revision: 275186
URL: https://svnweb.freebsd.org/changeset/base/275186

Log:
  MFC r273768:
  
  Remove the distinction between strings and numbers from ctld(8) yacc parser.
  This fixes problems with passing strings that look like numbers to clauses
  that expect strings; previously it caused syntax errors and had to be worked
  by user, using quotes.  The workaround introduced in r267833 is no longer
  neccessary.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  stable/10/usr.sbin/ctld/parse.y
  stable/10/usr.sbin/ctld/token.l
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/ctld/parse.y
==============================================================================
--- stable/10/usr.sbin/ctld/parse.y	Thu Nov 27 10:31:11 2014	(r275185)
+++ stable/10/usr.sbin/ctld/parse.y	Thu Nov 27 10:45:55 2014	(r275186)
@@ -101,21 +101,45 @@ statement:
 	target
 	;
 
-debug:		DEBUG NUM
+debug:		DEBUG STR
 	{
-		conf->conf_debug = $2;
+		uint64_t tmp;
+
+		if (expand_number($2, &tmp) != 0) {
+			log_warnx("invalid numeric value \"%s\"", $2);
+			free($2);
+			return (1);
+		}
+			
+		conf->conf_debug = tmp;
 	}
 	;
 
-timeout:	TIMEOUT NUM
+timeout:	TIMEOUT STR
 	{
-		conf->conf_timeout = $2;
+		uint64_t tmp;
+
+		if (expand_number($2, &tmp) != 0) {
+			log_warnx("invalid numeric value \"%s\"", $2);
+			free($2);
+			return (1);
+		}
+
+		conf->conf_timeout = tmp;
 	}
 	;
 
-maxproc:	MAXPROC NUM
+maxproc:	MAXPROC STR
 	{
-		conf->conf_maxproc = $2;
+		uint64_t tmp;
+
+		if (expand_number($2, &tmp) != 0) {
+			log_warnx("invalid numeric value \"%s\"", $2);
+			free($2);
+			return (1);
+		}
+
+		conf->conf_maxproc = tmp;
 	}
 	;
 
@@ -583,9 +607,17 @@ target_lun:	LUN lun_number
 	}
 	;
 
-lun_number:	NUM
+lun_number:	STR
 	{
-		lun = lun_new(target, $1);
+		uint64_t tmp;
+
+		if (expand_number($1, &tmp) != 0) {
+			log_warnx("invalid numeric value \"%s\"", $1);
+			free($1);
+			return (1);
+		}
+
+		lun = lun_new(target, tmp);
 		if (lun == NULL)
 			return (1);
 	}
@@ -626,15 +658,23 @@ lun_backend:	BACKEND STR
 	}
 	;
 
-lun_blocksize:	BLOCKSIZE NUM
+lun_blocksize:	BLOCKSIZE STR
 	{
+		uint64_t tmp;
+
+		if (expand_number($2, &tmp) != 0) {
+			log_warnx("invalid numeric value \"%s\"", $2);
+			free($2);
+			return (1);
+		}
+
 		if (lun->l_blocksize != 0) {
 			log_warnx("blocksize for lun %d, target \"%s\" "
 			    "specified more than once",
 			    lun->l_lun, target->t_name);
 			return (1);
 		}
-		lun_set_blocksize(lun, $2);
+		lun_set_blocksize(lun, tmp);
 	}
 	;
 
@@ -689,31 +729,26 @@ lun_serial:	SERIAL STR
 		}
 		lun_set_serial(lun, $2);
 		free($2);
-	} |	SERIAL NUM
+	}
+	;
+
+lun_size:	SIZE STR
 	{
-		char *str = NULL;
+		uint64_t tmp;
 
-		if (lun->l_serial != NULL) {
-			log_warnx("serial for lun %d, target \"%s\" "
-			    "specified more than once",
-			    lun->l_lun, target->t_name);
+		if (expand_number($2, &tmp) != 0) {
+			log_warnx("invalid numeric value \"%s\"", $2);
+			free($2);
 			return (1);
 		}
-		asprintf(&str, "%ju", $2);
-		lun_set_serial(lun, str);
-		free(str);
-	}
-	;
 
-lun_size:	SIZE NUM
-	{
 		if (lun->l_size != 0) {
 			log_warnx("size for lun %d, target \"%s\" "
 			    "specified more than once",
 			    lun->l_lun, target->t_name);
 			return (1);
 		}
-		lun_set_size(lun, $2);
+		lun_set_size(lun, tmp);
 	}
 	;
 %%

Modified: stable/10/usr.sbin/ctld/token.l
==============================================================================
--- stable/10/usr.sbin/ctld/token.l	Thu Nov 27 10:31:11 2014	(r275185)
+++ stable/10/usr.sbin/ctld/token.l	Thu Nov 27 10:45:55 2014	(r275186)
@@ -75,12 +75,6 @@ serial			{ return SERIAL; }
 size			{ return SIZE; }
 target			{ return TARGET; }
 timeout			{ return TIMEOUT; }
-[0-9]+[kKmMgGtTpPeE]?	{ if (expand_number(yytext, &yylval.num) == 0)
-				return NUM;
-			  else {
-				yylval.str = strdup(yytext); return STR;
-			  }
-			}
 \"[^"]+\"		{ yylval.str = strndup(yytext + 1,
 			    strlen(yytext) - 2); return STR; }
 [a-zA-Z0-9\.\-_/\:\[\]]+ { yylval.str = strdup(yytext); return STR; }



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