From owner-svn-src-all@FreeBSD.ORG Thu Nov 27 10:45:56 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CC9E15B2; Thu, 27 Nov 2014 10:45:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (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 B8770ED7; Thu, 27 Nov 2014 10:45:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sARAjuaS056716; Thu, 27 Nov 2014 10:45:56 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sARAjuo6056714; Thu, 27 Nov 2014 10:45:56 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201411271045.sARAjuo6056714@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Thu, 27 Nov 2014 10:45:56 +0000 (UTC) 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 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Nov 2014 10:45:56 -0000 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; }