aboutsummaryrefslogtreecommitdiff
path: root/src/sg_prevent.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2007-09-19 13:48:40 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2007-09-19 13:48:40 +0000
commitb6bc9ee42522285a70bcb1a4b81f052cc1c08bf6 (patch)
tree502c25bb85251fb8215a4305920ff004c6dcf2ad /src/sg_prevent.c
parentb28016b015c62fc9a94828aaea10a394112ee1be (diff)
downloadsg3_utils-b6bc9ee42522285a70bcb1a4b81f052cc1c08bf6.tar.gz
sg_stpg work, device_name simplification, restore sg_read_buffer to build
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@103 6180dd3e-e324-4e3e-922d-17de1ae2f315
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;