diff options
author | charnier <charnier@FreeBSD.org> | 1997-10-06 11:36:08 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-10-06 11:36:08 +0000 |
commit | e1eba2d48d55ccab7473f0ec67ac16b5daed99c7 (patch) | |
tree | bb6d02b48f43f60570e6d0c1d1f9b1d689b66624 /usr.sbin/pccard/pccardc/wrattr.c | |
parent | 2fef004dcf2789eb4481b4022d97dcc520b07d42 (diff) | |
download | FreeBSD-src-e1eba2d48d55ccab7473f0ec67ac16b5daed99c7.zip FreeBSD-src-e1eba2d48d55ccab7473f0ec67ac16b5daed99c7.tar.gz |
Use err(3). Add usage()s.
Diffstat (limited to 'usr.sbin/pccard/pccardc/wrattr.c')
-rw-r--r-- | usr.sbin/pccard/pccardc/wrattr.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/usr.sbin/pccard/pccardc/wrattr.c b/usr.sbin/pccard/pccardc/wrattr.c index 45b5abf..ec29bf8 100644 --- a/usr.sbin/pccard/pccardc/wrattr.c +++ b/usr.sbin/pccard/pccardc/wrattr.c @@ -22,18 +22,30 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id$ */ + +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ + +#include <err.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include <fcntl.h> #include <sys/types.h> #include <sys/ioctl.h> #include <pccard/card.h> +static void +usage() +{ + fprintf(stderr, "usage: pccardc wrattr slot offs value\n"); + exit(1); +} + int wrattr_main(argc, argv) int argc; @@ -44,30 +56,22 @@ wrattr_main(argc, argv) int fd; off_t offs; - if (argc != 4) { - fprintf(stderr, "usage: %s wrattr slot offs value\n", argv[0]); - exit(1); - } + if (argc != 4) + usage(); sprintf(name, CARD_DEVICE, atoi(argv[1])); fd = open(name, 2); - if (fd < 0) { - perror(name); - exit(1); - } + if (fd < 0) + err(1, "%s", name); reg = MDF_ATTR; - if (ioctl(fd, PIOCRWFLAG, ®)) { - perror("ioctl (PIOCRWFLAG)"); - exit(1); - } + if (ioctl(fd, PIOCRWFLAG, ®)) + err(1, "ioctl (PIOCRWFLAG)"); if (sscanf(argv[2], "%x", ®) != 1 || - sscanf(argv[3], "%x", &value) != 1) { - fprintf(stderr, "arg error\n"); - exit(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) - perror(name); + warn("%s", name); return 0; } |