Use xfopen, saves 32 bytes !
This commit is contained in:
parent
ad117d8a21
commit
bf265daa47
@ -37,16 +37,15 @@
|
|||||||
extern int
|
extern int
|
||||||
freeramdisk_main(int argc, char **argv)
|
freeramdisk_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int f;
|
FILE *f;
|
||||||
|
|
||||||
if (argc != 2 || *argv[1] == '-') {
|
if (argc != 2 || *argv[1] == '-') {
|
||||||
show_usage();
|
show_usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((f = open(argv[1], O_RDWR)) == -1) {
|
f = xfopen(argv[1], "r+");
|
||||||
perror_msg_and_die("cannot open %s", argv[1]);
|
|
||||||
}
|
if (ioctl(fileno(f), BLKFLSBUF) < 0) {
|
||||||
if (ioctl(f, BLKFLSBUF) < 0) {
|
|
||||||
perror_msg_and_die("failed ioctl on %s", argv[1]);
|
perror_msg_and_die("failed ioctl on %s", argv[1]);
|
||||||
}
|
}
|
||||||
/* Don't bother closing. Exit does
|
/* Don't bother closing. Exit does
|
||||||
|
@ -37,16 +37,15 @@
|
|||||||
extern int
|
extern int
|
||||||
freeramdisk_main(int argc, char **argv)
|
freeramdisk_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int f;
|
FILE *f;
|
||||||
|
|
||||||
if (argc != 2 || *argv[1] == '-') {
|
if (argc != 2 || *argv[1] == '-') {
|
||||||
show_usage();
|
show_usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((f = open(argv[1], O_RDWR)) == -1) {
|
f = xfopen(argv[1], "r+");
|
||||||
perror_msg_and_die("cannot open %s", argv[1]);
|
|
||||||
}
|
if (ioctl(fileno(f), BLKFLSBUF) < 0) {
|
||||||
if (ioctl(f, BLKFLSBUF) < 0) {
|
|
||||||
perror_msg_and_die("failed ioctl on %s", argv[1]);
|
perror_msg_and_die("failed ioctl on %s", argv[1]);
|
||||||
}
|
}
|
||||||
/* Don't bother closing. Exit does
|
/* Don't bother closing. Exit does
|
||||||
|
Loading…
Reference in New Issue
Block a user