Clean up usbaudio, usbmouse.
[rsc] --rw-rw-r-- M 1118886 sape sys 9843 Jan 23 09:37 sys/src/cmd/usb/audio/usbaudio.c
/n/sourcesdump/2006/0123/plan9/sys/src/cmd/usb/audio/usbaudio.c:16,22 -
/n/sourcesdump/2006/0124/plan9/sys/src/cmd/usb/audio/usbaudio.c:16,22
Channel *controlchan;
- char audstr[] = "Enabled 0x000101\n"; /* audio.control.0 */
+ char audstr[] = "Enabled 0x000101"; /* audio.control.0 */
int defaultspeed[2] = {44100, 44100};
[rsc] --rw-rw-r-- M 1118886 sape sys 3475 Jan 23 09:37 sys/src/cmd/usb/misc/usbmouse.c
/n/sourcesdump/2006/0123/plan9/sys/src/cmd/usb/misc/usbmouse.c:1,11 -
/n/sourcesdump/2006/0124/plan9/sys/src/cmd/usb/misc/usbmouse.c:1,10
#include <u.h>
#include <libc.h>
#include <thread.h>
- #include <stdio.h>
int mousefd, ctlfd, mousein;
- char hbm[] = "Enabled 0x020103\n";
+ char hbm[] = "Enabled 0x020103";
char *mouseinfile = "/dev/mousein";
char *statfmt = "/dev/usb%d/%d/status";
char *ctlfmt = "/dev/usb%d/%d/ctl";
/n/sourcesdump/2006/0123/plan9/sys/src/cmd/usb/misc/usbmouse.c:87,94 -
/n/sourcesdump/2006/0124/plan9/sys/src/cmd/usb/misc/usbmouse.c:86,92
void
threadmain(int argc, char *argv[])
{
- FILE *f;
- int ctlrno, i;
+ int ctlrno, i, sfd;
char line[256];
ARGBEGIN{
/n/sourcesdump/2006/0123/plan9/sys/src/cmd/usb/misc/usbmouse.c:112,128 -
/n/sourcesdump/2006/0124/plan9/sys/src/cmd/usb/misc/usbmouse.c:110,126
case 0:
for (ctlrno = 0; ctlrno < 16; ctlrno++) {
for (i = 0; i < 128; i++) {
- sprint(line, statfmt, ctlrno, i);
- f = fopen(line, "r");
- if (f == nil)
+ snprint(line, sizeof line, statfmt, ctlrno, i);
+ sfd = open(line, OREAD);
+ if (sfd < 0)
break;
- if (fgets(line, sizeof line, f) && strcmp(hbm, line) == 0) {
+ if (read(sfd, line, strlen(hbm)) && strncmp(hbm, line, strlen(hbm)) == 0) {
snprint(ctlfile, sizeof ctlfile, ctlfmt, ctlrno, i);
snprint(msefile, sizeof msefile, msefmt, ctlrno, i);
- fclose(f);
+ close(sfd);
goto found;
}
- fclose(f);
+ close(sfd);
}
}
threadexitsall("no mouse");
|