[#8484] strptime fails to properly parse certain inputs — <noreply@...>

Bugs item #5263, was opened at 2006-08-01 23:14

13 messages 2006/08/02
[#8485] Re: [ ruby-Bugs-5263 ] strptime fails to properly parse certain inputs — Yukihiro Matsumoto <matz@...> 2006/08/02

Hi,

[#8538] Re: [ ruby-Bugs-5263 ] strptime fails to properly parse certain inputs — nobu@... 2006/08/06

Hi,

[#8561] sandbox timers & block scopes — why the lucky stiff <ruby-core@...>

Two puzzles I am trying to solve:

28 messages 2006/08/08
[#8624] Re: sandbox timers & block scopes — why the lucky stiff <ruby-core@...> 2006/08/15

raise ThisDecayingInquisition, "anyone? anyone at all?"

[#8627] Re: sandbox timers & block scopes — MenTaLguY <mental@...> 2006/08/15

On Wed, 2006-08-16 at 00:35 +0900, why the lucky stiff wrote:

[#8628] Re: sandbox timers & block scopes — why the lucky stiff <ruby-core@...> 2006/08/15

On Wed, Aug 16, 2006 at 02:46:30AM +0900, MenTaLguY wrote:

[#8629] Re: sandbox timers & block scopes — "Charles O Nutter" <headius@...> 2006/08/15

On 8/15/06, why the lucky stiff <ruby-core@whytheluckystiff.net> wrote:

[#8690] a ruby-core primer — why the lucky stiff <ruby-core@...>

Hello, all. I've been working on the ruby-core page for the new Ruby site.

21 messages 2006/08/22

Building with -Wall => questions

From: Hugh Sasse <hgs@...>
Date: 2006-08-21 16:36:43 UTC
List: ruby-core #8667
Having built the 1.8.5-preview4 ruby on Solaris9, I wondered if
there was anything I could contribute before the final release.
I've been reading Code Quality by Spinellis
http://www.spinellis.gr/codequality/
and saw the remarks about turning warnings on to find more edge cases.
So I just tried changing CFLAGS in the Makefile to include -Wall.
The first part of the results is like this:

neelix hgs 12 %> gmake
gcc -Wall -g -O2  -DRUBY_EXPORT  -Wall -I. -I.  -c array.c
gcc -Wall -g -O2  -DRUBY_EXPORT  -Wall -I. -I.  -c bignum.c
bignum.c: In function 'rb_cstr_to_inum':
bignum.c:457: warning: suggest parentheses around assignment used as truth value
gcc -Wall -g -O2  -DRUBY_EXPORT  -Wall -I. -I.  -c class.c
gcc -Wall -g -O2  -DRUBY_EXPORT  -Wall -I. -I.  -c compar.c
gcc -Wall -g -O2  -DRUBY_EXPORT  -Wall -I. -I.  -c dir.c
dir.c: In function 'fnmatch':
dir.c:161: warning: suggest parentheses around assignment used as truth value
dir.c: In function 'glob_helper':
dir.c:982: warning: value computed is not used
dir.c:1009: warning: value computed is not used
dir.c:1025: warning: value computed is not used
dir.c:1053: warning: value computed is not used
dir.c:1100: warning: value computed is not used
gcc -Wall -g -O2  -DRUBY_EXPORT  -Wall -I. -I.  -c dln.c
dln.c: In function 'dln_find_1':


The "suggest parentheses around assignment" isn't really important, it
means 
neelix hgs 51 %> gdiff -pu1 bignum.c.orig bignum.c
--- bignum.c.orig       2006-04-09 16:10:36.000000000 +0000
+++ bignum.c    2006-08-21 15:29:17.189742000 +0000
@@ -456,3 +456,3 @@ rb_cstr_to_inum(str, base, badcheck)
     for (i=len;i--;) zds[i]=0;
-    while (c = *str++) {
+    while ((c = *str++)) {
        if (c == '_') {
neelix hgs 52 %>

In other words, use double parentheses to mark deliberate assignments.
One can debate whether that is right. A possible loss of clarity (extra
parentheses) is traded for a warning when -Wall is in effect.

The warnings for "value computed is not used" are all for 

            sys_warning(path);

and similar uses of sys_warning().  sys_warning is a macro

#define sys_warning(val) \
    ((flags & GLOB_VERBOSE) && rb_protect((VALUE (*)_((VALUE)))sys_warning_1, (VALUE)(val), 0))


Clearly the && is being used as a shortcut operator.  Kernighan and Pike

http://cm.bell-labs.com/cm/cs/tpop/

talks about macros, and generally discourages their use now that
compilers can do inlining.  Since the output of sys_warning is never
used, should this be changed into a void function?

And finally, should I just shut up?  Well, it probably needs asking:
now may well be the wrong time to mention such things so close to
1.8.5; there may be good reasons why macros are preferred over
functions for some platforms.  I can probably create some patches for
many of these cases but if now is not the time, then I'll leave it 
until later.

        Thank you,
        Hugh

In This Thread

Prev Next