aboutsummaryrefslogtreecommitdiff
path: root/src/sg_prevent.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sg_prevent.c')
-rw-r--r--src/sg_prevent.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/sg_prevent.c b/src/sg_prevent.c
index 030890a8..5f23b11d 100644
--- a/src/sg_prevent.c
+++ b/src/sg_prevent.c
@@ -46,7 +46,7 @@
* given SCSI device.
*/
-static char * version_str = "1.06 20070714";
+static char * version_str = "1.06 20070919";
#define ME "sg_prevent: "
@@ -87,10 +87,9 @@ int main(int argc, char * argv[])
int allow = 0;
int prevent = -1;
int verbose = 0;
- char device_name[256];
+ const char * device_name = NULL;
int ret = 0;
- memset(device_name, 0, sizeof device_name);
while (1) {
int option_index = 0;
@@ -127,9 +126,8 @@ int main(int argc, char * argv[])
}
}
if (optind < argc) {
- if ('\0' == device_name[0]) {
- strncpy(device_name, argv[optind], sizeof(device_name) - 1);
- device_name[sizeof(device_name) - 1] = '\0';
+ if (NULL == device_name) {
+ device_name = argv[optind];
++optind;
}
if (optind < argc) {
@@ -140,7 +138,7 @@ int main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
}
- if (0 == device_name[0]) {
+ if (NULL == device_name) {
fprintf(stderr, "missing device name!\n");
usage();
return SG_LIB_SYNTAX_ERROR;