incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Lemings" <Eric.Lemi...@roguewave.com>
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/
Date Fri, 30 May 2008 18:14:54 GMT
 

> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Friday, May 23, 2008 2:05 PM
> 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/
> 
...
> >  #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.)

Will do.

> 
> >  #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.

strtoul() would still cause a conversion warning, wouldn't it?

> 
> >                  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 ;-)

Depends on how the parameter is used within get_long_val().  If its
converted again, that'll just move conversion warnings from one
place to another.  I'll have to check it out.

> 
> >                  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...

I noticed the same and not only here but I limited my changes only
to what the issue calls for.

> 
> >                  }
> >              }
> >              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).

I can start filing minor issues for mo' betta range checking
on program options when I find such lax usage in the future.

Brad.

Mime
View raw message