Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 96918 invoked from network); 23 May 2008 20:05:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 May 2008 20:05:10 -0000 Received: (qmail 41418 invoked by uid 500); 23 May 2008 20:05:11 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 41404 invoked by uid 500); 23 May 2008 20:05:11 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 41393 invoked by uid 99); 23 May 2008 20:05:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 May 2008 13:05:11 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.roguewave.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 May 2008 20:04:24 +0000 Received: from nebula.bco.roguewave.com ([10.70.3.27]) by moroha.roguewave.com (8.13.6/8.13.6) with ESMTP id m4NK4bBm026689 for ; Fri, 23 May 2008 20:04:37 GMT Message-ID: <48372356.30408@roguewave.com> Date: Fri, 23 May 2008 14:04:38 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: dev@stdcxx.apache.org Subject: Re: svn commit: r659253 - in /stdcxx/branches/4.2.x: examples/manual/ src/ tests/algorithms/ tests/containers/ tests/localization/ tests/numerics/ tests/regress/ tests/src/ tests/strings/ util/ References: <20080522205446.F2AE02388A1F@eris.apache.org> In-Reply-To: <20080522205446.F2AE02388A1F@eris.apache.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org elemings@apache.org wrote: > Author: elemings > Date: Thu May 22 13:54:39 2008 > New Revision: 659253 > > URL: http://svn.apache.org/viewvc?rev=659253&view=rev > Log: > 2008-05-22 Eric Lemings > > STDCXX-550 [...] > * util/cmdopt.cpp: Explicitly cast return value of sysconf() > function to `float' type used by `TICKS_PER_SEC' global. > (eval_options): Cast return value of strtol() function to > `unsigned' type. Second parameter of get_long_val() function > expects `unsigned' type (go figure). Cast return value of > sizeof operator. exit() function expects `int' status code. > Parameter type of rw_sleep() function is `int'. [...] > Modified: stdcxx/branches/4.2.x/util/cmdopt.cpp > URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/cmdopt.cpp?rev=659253&r1=659252&r2=659253&view=diff > ============================================================================== > --- stdcxx/branches/4.2.x/util/cmdopt.cpp (original) > +++ stdcxx/branches/4.2.x/util/cmdopt.cpp Thu May 22 13:54:39 2008 > @@ -59,7 +59,7 @@ > const char suffix_sep = '.'; > const size_t exe_suffix_len = 0; > #if defined (_SC_CLK_TCK) > -const float TICKS_PER_SEC = sysconf (_SC_CLK_TCK); > +const float TICKS_PER_SEC = float (sysconf (_SC_CLK_TCK)); (As an aside, I wonder why this is defined here when the only place it's used is display.cpp. We should move it there.) > #elif defined (CLK_TCK) > const float TICKS_PER_SEC = CLK_TCK; > #elif defined (CLOCKS_PER_SEC) > @@ -521,7 +521,7 @@ > bad_value (optname, optarg); > > errno = 0; > - defaults->timeout = strtol (optarg, &end, 10); > + defaults->timeout = unsigned (strtol (optarg, &end, 10)); I suggest using strtoul() here instead. > if (*end || errno) > bad_value (optname, optarg); > } > @@ -573,7 +573,7 @@ > && !memcmp (opt_exit, argv [i], sizeof opt_exit - 1)) { > /* exit immediately with the specified status */ > optname = opt_exit; > - optarg = get_long_val (argv, &i, sizeof opt_exit - 1); > + optarg = get_long_val (argv, &i, unsigned (sizeof opt_exit - 1)); I suggest changing the get_long_val() signature to take size_t as the last argument (it will also help reduce the line length under 80 characters ;-) > if (optarg && *optarg) { > if (!isdigit (*optarg)) > bad_value (optname, optarg); > @@ -581,7 +581,7 @@ > errno = 0; > const long code = strtol (optarg, &end, 10); > if ('\0' == *end && !errno) > - exit (code); > + exit (int (code)); Seems this code (not necessarily the change) could do with some error checking and reporting... > } > } > else if ( sizeof opt_help - 1 == arglen > @@ -595,7 +595,7 @@ > && !memcmp (opt_sleep, argv [i], sizeof opt_sleep - 1)) { > /* sleep for the specified number of seconds */ > optname = opt_sleep; > - optarg = get_long_val (argv, &i, sizeof opt_sleep - 1); > + optarg = get_long_val (argv, &i, unsigned (sizeof opt_sleep - 1)); > if (optarg && *optarg) { > if (!isdigit (*optarg)) > bad_value (optname, optarg); > @@ -603,7 +603,7 @@ > errno = 0; > const long nsec = strtol (optarg, &end, 10); > if ('\0' == *end && 0 <= nsec && !errno) { > - rw_sleep (nsec); > + rw_sleep (int (nsec)); Same here (e.g., passing in a very large number on the command line as a result of a scripting error). Martin