[illumos-Developer] Bug #1031
Yuri Pankov
yuri.pankov at gmail.com
Wed May 18 04:23:42 PDT 2011
On Tue, May 17, 2011 at 04:33:44PM -0700, Garrett D'Amore wrote:
> 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.
How about the attached diff?
altair:yuri:~/ws/illumos/usr/src/cmd/audio/audioctl$ ./audioctl
show-device -d audiohd#1
Device: /dev/sound/audiohd:1mixer
Name = audiohd#1
Config = onboard1 (a)
HW Info = Unknown HD codec: 0x10de000a Unknown HD codec: 0x10de000a Unknown HD codec: 0x10de000a Unknown HD codec: 0x10de000a
altair:yuri:~/ws/illumos/usr/src/cmd/audio/audioctl$ ./audioctl
save-controls -d audiohd#1 -f audiohd1; cat audiohd1
Bad enum index 10 for control 'record-source'
# Device: /dev/sound/audiohd:1mixer
# Name = audiohd#1
# Config = onboard1 (a)
# HW Info = Unknown HD codec: 0x10de000a Unknown HD codec: 0x10de000a Unknown HD codec: 0x10de000a Unknown HD codec: 0x10de000a
#
#CONTROL VALUE
volume 75
("Bad enum.." is unrelated).
Yuri
> 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
>
> _______________________________________________
> Developer mailing list
> Developer at lists.illumos.org
> http://lists.illumos.org/m/listinfo/developer
>
-------------- next part --------------
diff -r 5e6d930c0c9b usr/src/cmd/audio/audioctl/audioctl.c
--- a/usr/src/cmd/audio/audioctl/audioctl.c Tue May 17 12:36:01 2011 -0400
+++ b/usr/src/cmd/audio/audioctl/audioctl.c Wed May 18 15:16:52 2011 +0400
@@ -831,7 +831,7 @@
do_show_device(int argc, char **argv)
{
int optc;
- char *devname = NULL;
+ char *devname = NULL, *p;
device_t *d;
while ((optc = getopt(argc, argv, "d:v")) != EOF) {
@@ -862,7 +862,9 @@
msg(_(" Config = %s\n"), d->card.longname);
if (strlen(d->card.hw_info)) {
- msg(_(" HW Info = %s"), d->card.hw_info);
+ while ((p = strchr(d->card.hw_info, '\n')) != NULL)
+ *p = ' ';
+ msg(_(" HW Info = %s\n"), d->card.hw_info);
}
return (0);
@@ -1010,6 +1012,7 @@
FILE *fp;
int fd;
int mode;
+ char *p;
mode = O_WRONLY | O_CREAT | O_EXCL;
@@ -1057,7 +1060,9 @@
(void) fprintf(fp, "# Config = %s\n", d->card.longname);
if (strlen(d->card.hw_info)) {
- (void) fprintf(fp, "# HW Info = %s", d->card.hw_info);
+ while ((p = strchr(d->card.hw_info, '\n')) != NULL)
+ *p = ' ';
+ (void) fprintf(fp, "# HW Info = %s\n", d->card.hw_info);
}
(void) fprintf(fp, "#\n");
More information about the Developer
mailing list