From: Sean Chittenden Date: 2002-05-28T19:28:51+09:00 Subject: Re: The warns-a-thon continues... --TYecfFk8j8mZq+dy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline > > :*) Fixed some sprintf() format type mismatches > > > > Don't change all mechanically. > > I looked over these for a few minutes and couldn't see any harm in, > what I thought, was correcting them. > > > :- sprintf(buf, "$%c", node->nd_nth); > > :+ sprintf(buf, "$%ld", node->nd_nth); > > > > %lc > > I'm not an expert, or any where close, but if I'm reading node.h > right, nd_nth is a long. Shouldn't it be %ld? > > > :- sprintf(buf, "0%o", NUM2INT(v)); > > :+ sprintf(buf, "0%ld", NUM2INT(v)); > > > > %lo > > Corrected, thank you. > > > :- sprintf(buf, "0x%x", NUM2ULONG(v)); > > :+ sprintf(buf, "0x%ld", NUM2ULONG(v)); > > > > %lx > > Corrected, thank you. > > > :- if (c >= '0' && c <= '7' || c == '_') { > > :+ if (c >= '0' && (c <= '7' || c == '_')) { > > > > if ((c >= '0' && c <= '7') || c == '_') { > > Corrected, thank you. Updated patch attached. -sc Pushed send too quickly (translation: time for me to goto bed!). :) -sc -- Sean Chittenden --TYecfFk8j8mZq+dy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch 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 10:27:30 @@ -408,7 +408,7 @@ z = bignew(len, sign); zds = BDIGITS(z); for (i=len;i--;) zds[i]=0; - while (c = *str++) { + while ((c = *str++)) { switch (c) { case '8': case '9': if (base == 8) { @@ -1106,7 +1106,7 @@ yds = BDIGITS(y); if (ny == 0 && yds[0] == 0) rb_num_zerodiv(); - if (nx < ny || nx == ny && BDIGITS(x)[nx - 1] < BDIGITS(y)[ny - 1]) { + if (nx < ny || (nx == ny && BDIGITS(x)[nx - 1] < BDIGITS(y)[ny - 1])) { if (divp) *divp = rb_int2big(0); if (modp) *modp = x; return; 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 10:27:30 @@ -156,7 +156,7 @@ int period = !(flags & FNM_DOTMATCH); int nocase = flags & FNM_CASEFOLD; - while (c = *pat++) { + while ((c = *pat++)) { switch (c) { case '?': if (!*s || ISDIRSEP(*s) || PERIOD(s)) Index: eval.c =================================================================== RCS file: /src/ruby/eval.c,v retrieving revision 1.296 diff -u -r1.296 eval.c --- eval.c 2002/05/28 03:20:04 1.296 +++ eval.c 2002/05/28 10:27:32 @@ -987,7 +987,7 @@ int len = elen; if (RSTRING(epath)->ptr[0] == '#') epath = 0; - if (tail = strchr(einfo, '\n')) { + if ((tail = strchr(einfo, '\n'))) { len = tail - einfo; tail++; /* skip newline */ } @@ -1970,14 +1970,14 @@ case NODE_NTH_REF: if (RTEST(rb_reg_nth_defined(node->nd_nth, MATCH_DATA))) { - sprintf(buf, "$%d", node->nd_nth); + sprintf(buf, "$%ld", node->nd_nth); return buf; } break; case NODE_BACK_REF: if (RTEST(rb_reg_nth_defined(0, MATCH_DATA))) { - sprintf(buf, "$%c", node->nd_nth); + sprintf(buf, "$%ld", node->nd_nth); return buf; } break; @@ -4126,7 +4126,7 @@ VALUE eclass; va_init_list(args, data2); - while (eclass = va_arg(args, VALUE)) { + while ((eclass = va_arg(args, VALUE))) { if (rb_obj_is_kind_of(ruby_errinfo, eclass)) { handle = Qtrue; break; @@ -6627,7 +6627,7 @@ Data_Get_Struct(self, struct BLOCK, data); str = rb_str_new(0, strlen(cname)+6+16+1); /* 6:tags 16:addr 1:nul */ - sprintf(RSTRING(str)->ptr, "#<%s:0x%lx>", cname, data->tag); + sprintf(RSTRING(str)->ptr, "#<%s:0x%p>", cname, data->tag); RSTRING(str)->len = strlen(RSTRING(str)->ptr); if (OBJ_TAINTED(self)) OBJ_TAINT(str); Index: file.c =================================================================== RCS file: /src/ruby/file.c,v retrieving revision 1.100 diff -u -r1.100 file.c --- file.c 2002/05/14 06:22:25 1.100 +++ file.c 2002/05/28 10:27:32 @@ -329,13 +329,13 @@ if (i == 2) { /* mode */ char buf[32]; - sprintf(buf, "0%o", NUM2INT(v)); + sprintf(buf, "0%lo", NUM2INT(v)); rb_str_buf_cat2(str, buf); } else if (i == 0 || i == 6) { /* dev/rdev */ char buf[32]; - sprintf(buf, "0x%x", NUM2ULONG(v)); + sprintf(buf, "0x%lx", NUM2ULONG(v)); rb_str_buf_cat2(str, buf); } else { Index: intern.h =================================================================== RCS file: /src/ruby/intern.h,v retrieving revision 1.88 diff -u -r1.88 intern.h --- intern.h 2002/04/26 00:40:28 1.88 +++ intern.h 2002/05/28 10:27:32 @@ -284,12 +284,6 @@ /* parse.y */ EXTERN int ruby_sourceline; EXTERN char *ruby_sourcefile; -#define yyparse ruby_yyparse -#define yylex ruby_yylex -#define yyerror ruby_yyerror -#define yylval ruby_yylval -#define yychar ruby_yychar -#define yydebug ruby_yydebug int yyparse _((void)); ID rb_id_attrset _((ID)); void rb_parser_append_print _((void)); Index: io.c =================================================================== RCS file: /src/ruby/io.c,v retrieving revision 1.139 diff -u -r1.139 io.c --- io.c 2002/05/23 05:35:26 1.139 +++ io.c 2002/05/28 10:27:33 @@ -2081,7 +2081,7 @@ OpenFile *fptr, *orig; char *mode; int fd; - off_t pos; + off_t pos = 0; nfile = rb_io_get_io(nfile); if (rb_safe_level() >= 4 && (!OBJ_TAINTED(io) || !OBJ_TAINTED(nfile))) { @@ -3508,7 +3508,7 @@ VALUE *argv; { VALUE tmp, str; - int len; + int len = 0; if (argc == 1) len = NUM2INT(argv[0]); str = Qnil; 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 10:27:33 @@ -343,7 +343,7 @@ return; } - if (ivtbl = rb_generic_ivar_table(obj)) { + if ((ivtbl = rb_generic_ivar_table(obj))) { w_byte(TYPE_IVAR, arg); } Index: numeric.c =================================================================== RCS file: /src/ruby/numeric.c,v retrieving revision 1.48 diff -u -r1.48 numeric.c --- numeric.c 2002/05/14 06:22:26 1.48 +++ numeric.c 2002/05/28 10:27:34 @@ -851,7 +851,7 @@ char *s; sprintf(buf, "%-.10g", RFLOAT(val)->value); - if (s = strchr(buf, ' ')) *s = '\0'; + if ((s = strchr(buf, ' '))) *s = '\0'; rb_raise(rb_eRangeError, "float %s out of range of integer", buf); } @@ -960,7 +960,7 @@ char *s; sprintf(buf, "%-.10g", RFLOAT(val)->value); - if (s = strchr(buf, ' ')) *s = '\0'; + if ((s = strchr(buf, ' '))) *s = '\0'; rb_raise(rb_eRangeError, "float %s out of range of long long", buf); } Index: pack.c =================================================================== RCS file: /src/ruby/pack.c,v retrieving revision 1.38 diff -u -r1.38 pack.c --- pack.c 2002/05/21 05:39:19 1.38 +++ pack.c 2002/05/28 10:27:34 @@ -1549,7 +1549,7 @@ { VALUE str = infected_str_new(0, (send - s)*3/4, str); char *ptr = RSTRING(str)->ptr; - int a,b,c,d; + int a,b,c = 0,d; static int first = 1; static int b64_xtable[256]; @@ -1834,7 +1834,7 @@ if (n != 0) { uv &= (1<<(BYTEWIDTH-2-n)) - 1; while (n--) { - uv = uv << 6 | *p++ & ((1<<6)-1); + uv = uv << 6 | (*p++ & ((1<<6)-1)); } } return uv; Index: parse.y =================================================================== RCS file: /src/ruby/parse.y,v retrieving revision 1.172 diff -u -r1.172 parse.y --- parse.y 2002/05/22 09:37:45 1.172 +++ parse.y 2002/05/28 10:27:35 @@ -21,6 +21,13 @@ #include #include +#define yyparse ruby_yyparse +#define yylex ruby_yylex +#define yyerror ruby_yyerror +#define yylval ruby_yylval +#define yychar ruby_yychar +#define yydebug ruby_yydebug + #define ID_SCOPE_SHIFT 3 #define ID_SCOPE_MASK 0x07 #define ID_LOCAL 0x01 @@ -358,7 +365,7 @@ if (in_def || in_single) yyerror("alias within method"); - sprintf(buf, "$%c", $3->nd_nth); + sprintf(buf, "$%lc", $3->nd_nth); $$ = NEW_VALIAS($2, rb_intern(buf)); } | kALIAS tGVAR tNTH_REF @@ -3414,7 +3421,7 @@ if (!ISXDIGIT(c)) break; nondigit = 0; tokadd(c); - } while (c = nextc()); + } while ((c = nextc())); } pushback(c); tokfix(); @@ -3438,7 +3445,7 @@ if (c != '0' && c != '1') break; nondigit = 0; tokadd(c); - } while (c = nextc()); + } while ((c = nextc())); } pushback(c); tokfix(); @@ -3449,7 +3456,7 @@ yylval.val = rb_cstr_to_inum(tok(), 2, Qfalse); return tINTEGER; } - if (c >= '0' && c <= '7' || c == '_') { + if ((c >= '0' && c <= '7') || c == '_') { /* octal */ do { if (c == '_') { @@ -3460,7 +3467,7 @@ if (c < '0' || c > '7') break; nondigit = 0; tokadd(c); - } while (c = nextc()); + } while ((c = nextc())); if (toklen() > start) { pushback(c); tokfix(); @@ -3930,7 +3937,7 @@ else { if (lex_state == EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && - (!peek('=') || lex_p + 1 < lex_pend && lex_p[1] == '>')) { + (!peek('=') || (lex_p + 1 < lex_pend && lex_p[1] == '>'))) { result = tIDENTIFIER; tokadd(c); } 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 10:27:35 @@ -562,8 +562,8 @@ 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")) { + if ((*a++ = strtok(ss, " \t"))) { + while ((t = strtok(NULL, " \t"))) { *a++ = t; } *a = NULL; 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 10:27:35 @@ -79,7 +79,7 @@ int tmp; while (len--) { - if (tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++]) + if ((tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++])) 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 10:27:35 @@ -46,7 +46,7 @@ VALUE ruby_verbose = Qfalse; static int sflag = 0; static int xflag = 0; -extern int yydebug; +extern int ruby_yydebug; char *ruby_inplace_mode = Qfalse; @@ -187,7 +187,7 @@ p = path; while (*p) { while (*p == sep) p++; - if (s = strchr(p, sep)) { + if ((s = strchr(p, sep))) { rb_ary_push(ary, rubylib_mangled_path(p, (int)(s-p))); p = s + 1; } @@ -353,7 +353,7 @@ if (s[1] == '-' && s[2] == '\0') break; s[0] = '$'; - if (p = strchr(s, '=')) { + if ((p = strchr(s, '='))) { *p++ = '\0'; rb_gv_set(s, rb_str_new2(p)); } @@ -436,7 +436,7 @@ goto reswitch; case 'y': - yydebug = 1; + ruby_yydebug = 1; s++; goto reswitch; @@ -594,7 +594,7 @@ goto reswitch; case '-': - if (!s[1] || s[1] == '\r' && !s[2]) { + if (!s[1] || ((s[1] == '\r') && !s[2])) { argc--,argv++; goto switch_end; } @@ -612,7 +612,7 @@ ruby_verbose = Qtrue; } else if (strcmp("yydebug", s) == 0) - yydebug = 1; + ruby_yydebug = 1; else if (strcmp("help", s) == 0) { usage(origargv[0]); exit(0); @@ -781,7 +781,7 @@ if (RSTRING(line)->len > 2 && RSTRING(line)->ptr[0] == '#' && RSTRING(line)->ptr[1] == '!') { - if (p = strstr(RSTRING(line)->ptr, "ruby")) { + if ((p = strstr(RSTRING(line)->ptr, "ruby"))) { goto start_read; } } @@ -833,7 +833,7 @@ 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, " -")) { + if ((p = strstr(p, " -"))) { p++; /* skip space before `-' */ while (*p == '-') { p = moreswitches(p+1); Index: st.c =================================================================== RCS file: /src/ruby/st.c,v retrieving revision 1.21 diff -u -r1.21 st.c --- st.c 2002/04/25 13:55:58 1.21 +++ st.c 2002/05/28 10:27:35 @@ -1,6 +1,6 @@ /* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */ -static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible"; +/* static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible"; */ #include "config.h" #include Index: string.c =================================================================== RCS file: /src/ruby/string.c,v retrieving revision 1.102 diff -u -r1.102 string.c --- string.c 2002/04/24 04:54:14 1.102 +++ string.c 2002/05/28 10:27:36 @@ -2444,7 +2444,7 @@ VALUE spat; VALUE limit; int char_sep = -1; - long beg, end, i; + long beg, end, i = 0; int lim = 0; VALUE result, tmp; Index: struct.c =================================================================== RCS file: /src/ruby/struct.c,v retrieving revision 1.33 diff -u -r1.33 struct.c --- struct.c 2002/05/14 06:22:26 1.33 +++ struct.c 2002/05/28 10:27:36 @@ -213,7 +213,7 @@ ary = rb_ary_new(); va_init_list(ar, name); - while (mem = va_arg(ar, char*)) { + while ((mem = va_arg(ar, char*))) { ID slot = rb_intern(mem); rb_ary_push(ary, ID2SYM(slot)); } Index: util.c =================================================================== RCS file: /src/ruby/util.c,v retrieving revision 1.25 diff -u -r1.25 util.c --- util.c 2002/05/14 06:22:26 1.25 +++ util.c 2002/05/28 10:27:36 @@ -12,6 +12,7 @@ #include "ruby.h" +#include #include #include Index: ext/etc/etc.c =================================================================== RCS file: /src/ruby/ext/etc/etc.c,v retrieving revision 1.5 diff -u -r1.5 etc.c --- ext/etc/etc.c 2001/12/18 08:47:00 1.5 +++ ext/etc/etc.c 2002/05/28 10:27:36 @@ -135,13 +135,13 @@ if (rb_block_given_p()) { setpwent(); - while (pw = getpwent()) { + while ((pw = getpwent())) { rb_yield(setup_passwd(pw)); } endpwent(); return obj; } - if (pw = getpwent()) { + if ((pw = getpwent())) { return setup_passwd(pw); } #endif @@ -212,13 +212,13 @@ if (rb_block_given_p()) { setgrent(); - while (grp = getgrent()) { + while ((grp = getgrent())) { rb_yield(setup_group(grp)); } endgrent(); return obj; } - if (grp = getgrent()) { + if ((grp = getgrent())) { return setup_group(grp); } #endif --TYecfFk8j8mZq+dy--