[illumos-Developer] Bug #1031

Garrett D'Amore garrett at damore.org
Tue May 17 16:33:44 PDT 2011


So I had another look... the code isn't right.. there will be multiple newlines, so you need to print the prefix for the first newline, but not the second ones.  I should have paid closer attention.

  -- Garrett D'Amore

On May 17, 2011, at 2:59 PM, Ben Taylor <bentaylor.solx86 at gmail.com> wrote:

> 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
> 
> _______________________________________________
> Developer mailing list
> Developer at lists.illumos.org
> http://lists.illumos.org/m/listinfo/developer



More information about the Developer mailing list