On Oct 12, 2012, at 7:06 AM, Aleksej Saushev wrote: > "David A. Holland" <dholl...@netbsd.org> > writes: > >> Module Name: src >> Committed By: dholland >> Date: Fri Oct 12 10:38:53 UTC 2012 >> >> Modified Files: >> src/games/adventure: wizard.c >> >> Log Message: >> Pass -Wstrict-overflow. >> >> >> To generate a diff of this commit: >> cvs rdiff -u -r1.14 -r1.15 src/games/adventure/wizard.c >> >> Please note that diffs are not public domain; they are subject to the >> copyright notices on the relevant files. >> >> >> Modified files: >> >> >> Index: src/games/adventure/wizard.c >> diff -u src/games/adventure/wizard.c:1.14 src/games/adventure/wizard.c:1.15 >> --- src/games/adventure/wizard.c:1.14 Tue Aug 25 06:56:52 2009 >> +++ src/games/adventure/wizard.c Fri Oct 12 10:38:53 2012 > > ... > >> @@ -130,19 +130,19 @@ wizard(void) >> void >> ciao(void) >> { >> - char *c; >> - char fname[80]; >> + char fname[80]; >> + size_t pos; >> >> printf("What would you like to call the saved version?\n"); >> /* XXX - should use fgetln to avoid arbitrary limit */ >> - for (c = fname; c < fname + sizeof fname - 1; c++) { >> + for (pos = 0; pos < sizeof(fname - 1); pos++) { > > "sizeof(fname-1)"?? > > (Isn't PATH_MAX better approximation to file name limit?)
and sizeof(fname - 1) is likely 4 or 8 since fname - 1 is a pointer and no longer an array. I think this is a typo for sizeof(fname) - 1. >> int ch; >> ch = getchar(); >> if (ch == '\n' || ch == EOF) >> break; >> - *c = ch; >> + fname[pos] = ch; >> } >> - *c = 0; >> + fname[pos] = '\0'; >> if (save(fname) != 0) >> return; /* Save failed */ >> printf("To resume, say \"adventure %s\".\n", fname); > > -- > HE CE3OH... >