Use xfopen, saves 32 bytes !
authorGlenn L McGrath <bug1@ihug.co.nz>
Fri, 5 Oct 2001 05:03:14 +0000 (05:03 -0000)
committerGlenn L McGrath <bug1@ihug.co.nz>
Fri, 5 Oct 2001 05:03:14 +0000 (05:03 -0000)
freeramdisk.c
util-linux/freeramdisk.c

index cf25fae6abb61f6d0cf27ff0a0aa29ab039c1ab3..aabb5f98827641ed79ef3c6fa890f6a338c4158b 100644 (file)
 extern int
 freeramdisk_main(int argc, char **argv)
 {
-       int   f;
+       FILE *f;
 
        if (argc != 2 || *argv[1] == '-') {
                show_usage();
        }
 
-       if ((f = open(argv[1], O_RDWR)) == -1) {
-               perror_msg_and_die("cannot open %s", argv[1]);
-       }
-       if (ioctl(f, BLKFLSBUF) < 0) {
+       f = xfopen(argv[1], "r+");
+       
+       if (ioctl(fileno(f), BLKFLSBUF) < 0) {
                perror_msg_and_die("failed ioctl on %s", argv[1]);
        }
        /* Don't bother closing.  Exit does
index cf25fae6abb61f6d0cf27ff0a0aa29ab039c1ab3..aabb5f98827641ed79ef3c6fa890f6a338c4158b 100644 (file)
 extern int
 freeramdisk_main(int argc, char **argv)
 {
-       int   f;
+       FILE *f;
 
        if (argc != 2 || *argv[1] == '-') {
                show_usage();
        }
 
-       if ((f = open(argv[1], O_RDWR)) == -1) {
-               perror_msg_and_die("cannot open %s", argv[1]);
-       }
-       if (ioctl(f, BLKFLSBUF) < 0) {
+       f = xfopen(argv[1], "r+");
+       
+       if (ioctl(fileno(f), BLKFLSBUF) < 0) {
                perror_msg_and_die("failed ioctl on %s", argv[1]);
        }
        /* Don't bother closing.  Exit does