mirror of
https://github.com/sheumann/hush.git
synced 2024-12-21 23:29:34 +00:00
This patch
- eliminates the need to have a buffer and strcpy to it - makes freeramdisk complain if it's given more than one argument Regards, Pavel Roskin
This commit is contained in:
parent
832000f7f3
commit
ef4268efa7
@ -49,6 +49,7 @@
|
||||
to Pavel Roskin.
|
||||
* Fixed all fatalError() calls lacking a "\n", thanks to Pavel Roskin.
|
||||
* Fixed a segfault in yes when no args were given -- Pavel Roskin.
|
||||
* Simplified freeramdisk and added argument checking -- Pavel Roskin.
|
||||
* More doc updates
|
||||
|
||||
|
||||
|
@ -43,21 +43,17 @@ static const char freeramdisk_usage[] =
|
||||
extern int
|
||||
freeramdisk_main(int argc, char **argv)
|
||||
{
|
||||
char rname[256] = "/dev/ram";
|
||||
int f;
|
||||
|
||||
if (argc < 2 || ( argv[1] && *argv[1] == '-')) {
|
||||
if (argc != 2 || *argv[1] == '-') {
|
||||
usage(freeramdisk_usage);
|
||||
}
|
||||
|
||||
if (argc >1)
|
||||
strcpy(rname, argv[1]);
|
||||
|
||||
if ((f = open(rname, O_RDWR)) == -1) {
|
||||
fatalError( "freeramdisk: cannot open %s: %s\n", rname, strerror(errno));
|
||||
if ((f = open(argv[1], O_RDWR)) == -1) {
|
||||
fatalError( "freeramdisk: cannot open %s: %s\n", argv[1], strerror(errno));
|
||||
}
|
||||
if (ioctl(f, BLKFLSBUF) < 0) {
|
||||
fatalError( "freeramdisk: failed ioctl on %s: %s\n", rname, strerror(errno));
|
||||
fatalError( "freeramdisk: failed ioctl on %s: %s\n", argv[1], strerror(errno));
|
||||
}
|
||||
/* Don't bother closing. Exit does
|
||||
* that, so we can save a few bytes */
|
||||
|
@ -43,21 +43,17 @@ static const char freeramdisk_usage[] =
|
||||
extern int
|
||||
freeramdisk_main(int argc, char **argv)
|
||||
{
|
||||
char rname[256] = "/dev/ram";
|
||||
int f;
|
||||
|
||||
if (argc < 2 || ( argv[1] && *argv[1] == '-')) {
|
||||
if (argc != 2 || *argv[1] == '-') {
|
||||
usage(freeramdisk_usage);
|
||||
}
|
||||
|
||||
if (argc >1)
|
||||
strcpy(rname, argv[1]);
|
||||
|
||||
if ((f = open(rname, O_RDWR)) == -1) {
|
||||
fatalError( "freeramdisk: cannot open %s: %s\n", rname, strerror(errno));
|
||||
if ((f = open(argv[1], O_RDWR)) == -1) {
|
||||
fatalError( "freeramdisk: cannot open %s: %s\n", argv[1], strerror(errno));
|
||||
}
|
||||
if (ioctl(f, BLKFLSBUF) < 0) {
|
||||
fatalError( "freeramdisk: failed ioctl on %s: %s\n", rname, strerror(errno));
|
||||
fatalError( "freeramdisk: failed ioctl on %s: %s\n", argv[1], strerror(errno));
|
||||
}
|
||||
/* Don't bother closing. Exit does
|
||||
* that, so we can save a few bytes */
|
||||
|
Loading…
Reference in New Issue
Block a user