[illumos-Developer] Bug #1031

Ben Taylor bentaylor.solx86 at gmail.com
Tue May 17 14:59:30 PDT 2011


2011/5/17 Γιώργος Γεωργίου <paogeorge13 at gmail.com>:
> Hello to all developers!
> This is my first touch with an open source project.
> I have a suggestion for solving this problem.
>
> fuction: int do_save_controls(int argc, char **argv)
> file: /illumos-gate/usr/src/cmd/audio/audioctl/audioctl.c
>
>
> Replace lines
>
>  1059 	if (strlen(d->card.hw_info)) {
>    1060 		(void) fprintf(fp, "# HW Info = %s", d->card.hw_info);
>    1061 	}
>    1062 	(void) fprintf(fp, "#\n");
>
>
>
> with lines below
>
> char *hwInfo;
>
> if (strlen(d->card.hw_info)) {
>
>           hwInfo = strtok (d->card.hw_info, "\n");
>
>           while (hwInfo != NULL) {
>
>                     (void) fprintf(fp, "# HW Info = %s\n", hwInfo);
>
>                     hwInfo = strtok(NULL, "\n");

Why not just set hwInfo to NULL here instead of using
strtok since its obvious that the while loop will execute just once.

And is it certain that d->card.hw_info will only contain one
line CR delimited line?

>
>           }
>
> }
>
> (void) fprintf(fp, "#\n");

Given that you've added a "\n" to the fprintf above, is this fprintf necessary?

Ben



More information about the Developer mailing list