From 6df3a4da61c19f60c3a5011b1e9d3206bf2ca36b Mon Sep 17 00:00:00 2001 From: kuriyama Date: Sat, 27 Feb 1999 12:08:02 +0000 Subject: Cleanup usage of err() and warn(). Add error handling for ioctl(). Reviewed by: -current Obtained from: PAO --- usr.sbin/pccard/pccardc/wrattr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'usr.sbin/pccard/pccardc/wrattr.c') diff --git a/usr.sbin/pccard/pccardc/wrattr.c b/usr.sbin/pccard/pccardc/wrattr.c index e7857b9..51b57bc 100644 --- a/usr.sbin/pccard/pccardc/wrattr.c +++ b/usr.sbin/pccard/pccardc/wrattr.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id: wrattr.c,v 1.10 1997/11/18 21:08:08 nate Exp $"; + "$Id: wrattr.c,v 1.11 1999/02/05 16:00:16 kuriyama Exp $"; #endif /* not lint */ #include @@ -62,16 +62,19 @@ wrattr_main(argc, argv) fd = open(name, O_RDWR); if (fd < 0) err(1, "%s", name); + reg = MDF_ATTR; if (ioctl(fd, PIOCRWFLAG, ®)) err(1, "ioctl (PIOCRWFLAG)"); + if (sscanf(argv[2], "%x", ®) != 1 || sscanf(argv[3], "%x", &value) != 1) errx(1, "arg error"); + offs = reg; c = value; lseek(fd, offs, SEEK_SET); if (write(fd, &c, 1) != 1) - warn("%s", name); + err(1, "%s", name); return 0; } -- cgit v1.1