Re: The warns-a-thon continues...
From:
Michal Rokos <m.rokos@...>
Date:
2002-05-28 22:45:53 UTC
List:
ruby-core #79
Sean, others,
if you want to fix 'parens. around truth value' warning, could
this be a good approach?
(But I doubt that it has any sence to fix warnings like this.)
Michal
Index: bignum.c
===================================================================
RCS file: /src/ruby/bignum.c,v
retrieving revision 1.65
diff -u -r1.65 bignum.c
--- bignum.c 2002/05/14 06:22:25 1.65
+++ bignum.c 2002/05/28 22:32:14
@@ -408,7 +408,8 @@
z = bignew(len, sign);
zds = BDIGITS(z);
for (i=len;i--;) zds[i]=0;
- while (c = *str++) {
+ while (*str) {
+ c = *str++;
switch (c) {
case '8': case '9':
if (base == 8) {
Index: dir.c
===================================================================
RCS file: /src/ruby/dir.c,v
retrieving revision 1.70
diff -u -r1.70 dir.c
--- dir.c 2002/05/11 01:53:48 1.70
+++ dir.c 2002/05/28 22:32:15
@@ -156,7 +156,8 @@
int period = !(flags & FNM_DOTMATCH);
int nocase = flags & FNM_CASEFOLD;
- while (c = *pat++) {
+ while (*pat) {
+ c = *pat++;
switch (c) {
case '?':
if (!*s || ISDIRSEP(*s) || PERIOD(s))
Index: eval.c
===================================================================
RCS file: /src/ruby/eval.c,v
retrieving revision 1.297
diff -u -r1.297 eval.c
--- eval.c 2002/05/28 18:11:07 1.297
+++ eval.c 2002/05/28 22:32:26
@@ -987,7 +987,9 @@
int len = elen;
if (RSTRING(epath)->ptr[0] == '#') epath = 0;
- if (tail = strchr(einfo, '\n')) {
+
+ tail = strchr(einfo, '\n');
+ if (tail) {
len = tail - einfo;
tail++; /* skip newline */
}
@@ -4126,11 +4128,13 @@
VALUE eclass;
va_init_list(args, data2);
- while (eclass = va_arg(args, VALUE)) {
+ eclass = va_arg(args, VALUE);
+ while (eclass) {
if (rb_obj_is_kind_of(ruby_errinfo, eclass)) {
handle = Qtrue;
break;
}
+ eclass = va_arg(args, VALUE);
}
va_end(args);
Index: marshal.c
===================================================================
RCS file: /src/ruby/marshal.c,v
retrieving revision 1.61
diff -u -r1.61 marshal.c
--- marshal.c 2002/05/14 06:22:26 1.61
+++ marshal.c 2002/05/28 22:32:27
@@ -343,7 +343,8 @@
return;
}
- if (ivtbl = rb_generic_ivar_table(obj)) {
+ ivtbl = rb_generic_ivar_table(obj);
+ if (ivtbl) {
w_byte(TYPE_IVAR, arg);
}
Index: numeric.c
===================================================================
RCS file: /src/ruby/numeric.c,v
retrieving revision 1.49
diff -u -r1.49 numeric.c
--- numeric.c 2002/05/28 18:11:07 1.49
+++ numeric.c 2002/05/28 22:32:29
@@ -851,7 +851,9 @@
char *s;
sprintf(buf, "%-.10g", RFLOAT(val)->value);
- if (s = strchr(buf, ' ')) *s = '\0';
+
+ s = strchr(buf, ' ');
+ if (s) *s = '\0';
rb_raise(rb_eRangeError, "float %s out of range of integer", buf);
}
@@ -960,7 +962,9 @@
char *s;
sprintf(buf, "%-.10g", RFLOAT(val)->value);
- if (s = strchr(buf, ' ')) *s = '\0';
+
+ s = strchr(buf, ' ');
+ if (s) *s = '\0';
rb_raise(rb_eRangeError, "float %s out of range of long long", buf);
}
Index: parse.y
===================================================================
RCS file: /src/ruby/parse.y,v
retrieving revision 1.173
diff -u -r1.173 parse.y
--- parse.y 2002/05/28 18:11:07 1.173
+++ parse.y 2002/05/28 22:33:06
@@ -3414,7 +3414,8 @@
if (!ISXDIGIT(c)) break;
nondigit = 0;
tokadd(c);
- } while (c = nextc());
+ c = nextc();
+ } while (c);
}
pushback(c);
tokfix();
@@ -3438,7 +3439,8 @@
if (c != '0' && c != '1') break;
nondigit = 0;
tokadd(c);
- } while (c = nextc());
+ c = nextc();
+ } while (c);
}
pushback(c);
tokfix();
@@ -3460,7 +3462,9 @@
if (c < '0' || c > '7') break;
nondigit = 0;
tokadd(c);
- } while (c = nextc());
+ c = nextc();
+ } while (c);
+
if (toklen() > start) {
pushback(c);
tokfix();
@@ -4882,6 +4886,9 @@
else {
rb_warning("literal in condition");
}
+ break;
+ default:
+ break;
}
return node;
}
Index: process.c
===================================================================
RCS file: /src/ruby/process.c,v
retrieving revision 1.52
diff -u -r1.52 process.c
--- process.c 2002/05/14 06:22:26 1.52
+++ process.c 2002/05/28 22:33:14
@@ -562,12 +562,20 @@
a = argv = ALLOCA_N(char*, (s-str)/2+2);
ss = ALLOCA_N(char, s-str+1);
strcpy(ss, str);
- if (*a++ = strtok(ss, " \t")) {
- while (t = strtok(NULL, " \t")) {
+
+ *a = strtok(ss, " \t");
+ if (*a) {
+ *a++;
+
+ t = strtok(NULL, " \t");
+ while (t) {
*a++ = t;
+ t = strtok(NULL, " \t");
}
*a = NULL;
}
+ else *a++;
+
if (argv[0]) {
return proc_exec_v(argv, 0);
}
Index: re.c
===================================================================
RCS file: /src/ruby/re.c,v
retrieving revision 1.69
diff -u -r1.69 re.c
--- re.c 2002/05/14 06:22:26 1.69
+++ re.c 2002/05/28 22:33:21
@@ -79,7 +79,8 @@
int tmp;
while (len--) {
- if (tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++])
+ tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++];
+ if (tmp)
return tmp;
}
return 0;
Index: ruby.c
===================================================================
RCS file: /src/ruby/ruby.c,v
retrieving revision 1.61
diff -u -r1.61 ruby.c
--- ruby.c 2002/05/23 07:41:53 1.61
+++ ruby.c 2002/05/28 22:33:24
@@ -187,7 +187,8 @@
p = path;
while (*p) {
while (*p == sep) p++;
- if (s = strchr(p, sep)) {
+ s = strchr(p, sep);
+ if (s) {
rb_ary_push(ary, rubylib_mangled_path(p, (int)(s-p)));
p = s + 1;
}
@@ -353,7 +354,8 @@
if (s[1] == '-' && s[2] == '\0') break;
s[0] = '$';
- if (p = strchr(s, '=')) {
+ p = strchr(s, '=');
+ if (p) {
*p++ = '\0';
rb_gv_set(s, rb_str_new2(p));
}
@@ -781,7 +783,8 @@
if (RSTRING(line)->len > 2
&& RSTRING(line)->ptr[0] == '#'
&& RSTRING(line)->ptr[1] == '!') {
- if (p = strstr(RSTRING(line)->ptr, "ruby")) {
+ p = strstr(RSTRING(line)->ptr, "ruby");
+ if (p) {
goto start_read;
}
}
@@ -833,7 +836,9 @@
RSTRING(line)->ptr[RSTRING(line)->len-1] = '\0';
if (RSTRING(line)->ptr[RSTRING(line)->len-2] == '\r')
RSTRING(line)->ptr[RSTRING(line)->len-2] = '\0';
- if (p = strstr(p, " -")) {
+
+ p = strstr(p, " -");
+ if (p) {
p++; /* skip space before `-' */
while (*p == '-') {
p = moreswitches(p+1);
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Michal Rokos Czech Technical University, Prague
E-mail:m.rokos@sh.cvut.cz ICQ:36118339 Jabber:majkl@jabber.sh.cvut.cz
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-