Hey Guys, Below is a patch for the com32/rosh/rosh.c from tonights syslinx git. The patch does the following: 1) changes the rosh_issp to use an if instead of a case for this simple test. 2) changes the rosh_dir_arg function to move the readdir() to inside the while test. This will let me go through my APUE book. Let me know if you have any questions. Keith --- rosh.orig 2009-03-05 20:32:59.000000000 -0500 +++ rosh.c 2009-03-05 22:09:55.000000000 -0500 @@ -60,11 +60,11 @@ */ int rosh_issp(char inc) { - int rv; - switch (inc){ - case ' ': case '\t': - rv = 1; break; - default: rv = 0; + int rv = 0 ; + + if ( ( inc == ' ') || ( inc == '\t') ) + { + rv = 1 ; } return rv; } /* ros_issp */ @@ -384,8 +384,7 @@ if (S_ISDIR(fdstat.st_mode)) { ROSH_DEBUG("PATH '%s' is a directory\n", ifilstr); d = fdopendir(fd); - de = readdir(d); - while (de != NULL) { + while ( de = readdir(d) ) { #ifdef DO_DEBUG filestr2[0] = 0; file2pos = strlen(filestr); @@ -401,7 +400,6 @@ #ifdef DO_DEBUG // inchar = fgetc(stdin); #endif /* DO_DEBUG */ - de = readdir(d); } closedir(d); } else if (S_ISREG(fdstat.st_mode)) { @@ -419,8 +417,7 @@ d = opendir(filestr); if (d != NULL) { printf("DIR:'%s' %8d %8d\n", d->dd_name, d->dd_fd, d->dd_sect); - de = readdir(d); - while (de != NULL) { + while ( de = readdir(d) ) { filepos++; #ifdef DO_DEBUG // if (strlen(de->d_name) > 25) de->d_name[25] = 0; @@ -438,7 +435,6 @@ // fgets(instr, ROSH_CMD_SZ, stdin); #endif /* DO_DEBUG */ free(de); - de = readdir(d); // if(filepos>15){ de = NULL; printf("Force Break\n");} } printf("Dir.dd_fd: '%8d'\n", d->dd_fd);
Keith Schincke wrote:> Hey Guys, > > Below is a patch for the com32/rosh/rosh.c from tonights syslinx git. > The patch does the following: > 1) changes the rosh_issp to use an if instead of a case for this simple > test. > 2) changes the rosh_dir_arg function to move the readdir() to inside the > while test. > > This will let me go through my APUE book. > > Let me know if you have any questions. >You're saying WHAT you're proposing, but not WHY you're proposing it. Also, what is an "APUE book"? -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
IMHO, if your static checker is unsatisfied with simple int rosh_issp(char inc) { return ( ( inc == ' ') || ( inc == '\t') ); } /* ros_issp */ you should just make this function of type _Bool. Sergii Kolisnyk
Along that same theme, we could replace this with a ROSH_ISSPACE macro. Keith -----Original Message----- From: Sergii Kolisnyk <kolkmail at gmail.com> Sent: Friday, March 06, 2009 9:19 AM To: For discussion of Syslinux and tftp-hpa <syslinux at zytor.com> Subject: Re: [syslinux] rosh patch IMHO, if your static checker is unsatisfied with simple int rosh_issp(char inc) { return ( ( inc == ' ') || ( inc == '\t') ); } /* ros_issp */ you should just make this function of type _Bool. Sergii Kolisnyk _______________________________________________ Syslinux mailing list Submissions to Syslinux at zytor.com Unsubscribe or set options at: http://www.zytor.com/mailman/listinfo/syslinux Please do not send private replies to mailing list traffic.
On Thu, Mar 5, 2009 at 10:13 PM, Keith Schincke <keith.schincke at gmail.com> wrote:> Hey Guys, > > Below is a patch for the com32/rosh/rosh.c from tonights syslinx git. > The patch does the following: > ?1) changes the rosh_issp to use an if instead of a case for this simple > test. > ?2) changes the rosh_dir_arg function to move the readdir() to inside the > while test. > > This will let me go through my APUE book. > > Let me know if you have any questions. > > Keith > > --- rosh.orig ? 2009-03-05 20:32:59.000000000 -0500 > +++ rosh.c ? ? ?2009-03-05 22:09:55.000000000 -0500 > @@ -60,11 +60,11 @@ > ?*/ > ?int rosh_issp(char inc) > ?{ > - ? ? ? int rv; > - ? ? ? switch (inc){ > - ? ? ? case ' ': case '\t': > - ? ? ? ? ? ? ? rv = 1; break; > - ? ? ? default: rv = 0; > + ? ? ? int rv = 0 ; > + > + ? ? ? if ( ( inc == ' ') || ( inc == '\t') ) > + ? ? ? { > + ? ? ? ? ? ? ? rv = 1 ; > ? ? ? ?} > ? ? ? ?return rv; > ?} ? ? ?/* ros_issp */Presetting rv (and other simple return values) is something I think I'm going to have to do on quite a few functions. Thanks for noting it. As far as switch versus if, I'm definitely uncertain which is better. I should probably make another function that checks if it's a whitespace character as that's a little more relevant to what I'm trying to do. With regards to the braces, they're deemed unneeded as it's only one line.> @@ -384,8 +384,7 @@ > ? ? ? ? ? ? ? ?if (S_ISDIR(fdstat.st_mode)) { > ? ? ? ? ? ? ? ? ? ? ? ?ROSH_DEBUG("PATH '%s' is a directory\n", ifilstr); > ? ? ? ? ? ? ? ? ? ? ? ?d = fdopendir(fd); > - ? ? ? ? ? ? ? ? ? ? ? de = readdir(d); > - ? ? ? ? ? ? ? ? ? ? ? while (de != NULL) { > + ? ? ? ? ? ? ? ? ? ? ? while ( de = readdir(d) ) { > ?#ifdef DO_DEBUG > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?filestr2[0] = 0; > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?file2pos = strlen(filestr); > @@ -401,7 +400,6 @@ > ?#ifdef DO_DEBUG > ?// inchar = fgetc(stdin); > ?#endif /* DO_DEBUG */ > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? de = readdir(d); > ? ? ? ? ? ? ? ? ? ? ? ?} > ? ? ? ? ? ? ? ? ? ? ? ?closedir(d); > ? ? ? ? ? ? ? ?} else if (S_ISREG(fdstat.st_mode)) {OK. -- -Gene