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/pccardmem.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/pccardmem.c')
-rw-r--r-- | usr.sbin/pccard/pccardc/pccardmem.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/usr.sbin/pccard/pccardc/pccardmem.c b/usr.sbin/pccard/pccardc/pccardmem.c index 959db3a..059a571 100644 --- a/usr.sbin/pccard/pccardc/pccardmem.c +++ b/usr.sbin/pccard/pccardc/pccardmem.c @@ -22,16 +22,28 @@ * 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$ */ -#include <stdio.h> + +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ + +#include <err.h> #include <fcntl.h> +#include <stdio.h> #include <sys/types.h> #include <sys/ioctl.h> #include <pccard/card.h> +static void +usage() +{ + fprintf(stderr, "usage: pccardc pccardmem [memory-address]\n"); + exit(1); +} + int pccardmem_main(argc, argv) int argc; @@ -41,24 +53,18 @@ pccardmem_main(argc, argv) int addr = 0; int fd; - if (argc > 2) { - fprintf(stderr, "usage: %s [ memory-address ]\n", argv[0]); - exit(1); - } + if (argc > 2) + usage(); sprintf(name, CARD_DEVICE, 0); fd = open(name, 0); - if (fd < 0) { - perror(name); - exit(1); - } + if (fd < 0) + err(1, "%s", name); if (argc == 2) { - if (sscanf(argv[1], "%x", &addr) != 1) { - fprintf(stderr, "arg error\n"); - exit(1); - } + if (sscanf(argv[1], "%x", &addr) != 1) + errx(1, "arg error"); } if (ioctl(fd, PIOCRWMEM, &addr)) - perror("ioctl"); + warn("ioctl"); else printf("PCCARD Memory address set to 0x%x\n", addr); exit(0); |