summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath2001-10-05 05:03:14 +0000
committerGlenn L McGrath2001-10-05 05:03:14 +0000
commitbf265daa470d7647abb7d8738c6f6365bb3478f3 (patch)
tree7e2acd7f7164128440597cd5ec7bd8bd09f36542
parentad117d8a213979fae1bf6ec9162c2e998800b096 (diff)
downloadbusybox-bf265daa470d7647abb7d8738c6f6365bb3478f3.zip
busybox-bf265daa470d7647abb7d8738c6f6365bb3478f3.tar.gz
Use xfopen, saves 32 bytes !
-rw-r--r--freeramdisk.c9
-rw-r--r--util-linux/freeramdisk.c9
2 files changed, 8 insertions, 10 deletions
diff --git a/freeramdisk.c b/freeramdisk.c
index cf25fae..aabb5f9 100644
--- a/freeramdisk.c
+++ b/freeramdisk.c
@@ -37,16 +37,15 @@
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
diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c
index cf25fae..aabb5f9 100644
--- a/util-linux/freeramdisk.c
+++ b/util-linux/freeramdisk.c
@@ -37,16 +37,15 @@
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