Merge Trond.
[m6w6/libmemcached] / clients / memrm.c
index e7525fd5b6912edb438001eb379b4eed98d3c5e4..81c5f852bd21a992e718b86acb44e7c6203694c6 100644 (file)
@@ -28,7 +28,7 @@ static char *opt_hash= NULL;
 #define PROGRAM_DESCRIPTION "Erase a key or set of keys from a memcached cluster."
 
 /* Prototypes */
-void options_parse(int argc, char *argv[]);
+static void options_parse(int argc, char *argv[]);
 
 int main(int argc, char *argv[])
 {
@@ -36,6 +36,8 @@ int main(int argc, char *argv[])
   memcached_return_t rc;
   memcached_server_st *servers;
 
+  int return_code= 0;
+
   options_parse(argc, argv);
 
   if (!opt_servers)
@@ -59,20 +61,22 @@ int main(int argc, char *argv[])
   memcached_server_list_free(servers);
   memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
                          (uint64_t) opt_binary);
-  
-  while (optind < argc) 
+  while (optind < argc)
   {
-    if (opt_verbose) 
+    if (opt_verbose)
       printf("key: %s\nexpires: %llu\n", argv[optind], (unsigned long long)opt_expire);
     rc = memcached_delete(memc, argv[optind], strlen(argv[optind]), opt_expire);
 
-    if (rc != MEMCACHED_SUCCESS) 
+    if (rc != MEMCACHED_SUCCESS)
     {
-      fprintf(stderr, "memrm: %s: memcache error %s", 
+      fprintf(stderr, "memrm: %s: memcache error %s",
              argv[optind], memcached_strerror(memc, rc));
       if (memc->cached_errno)
        fprintf(stderr, " system error %s", strerror(memc->cached_errno));
       fprintf(stderr, "\n");
+
+      return_code= -1;
     }
 
     optind++;
@@ -85,11 +89,11 @@ int main(int argc, char *argv[])
   if (opt_hash)
     free(opt_hash);
 
-  return 0;
+  return return_code;
 }
 
 
-void options_parse(int argc, char *argv[])
+static void options_parse(int argc, char *argv[])
 {
   memcached_programs_help_st help_options[]=
   {
@@ -111,7 +115,7 @@ void options_parse(int argc, char *argv[])
   int option_index= 0;
   int option_rv;
 
-  while (1) 
+  while (1)
   {
     option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index);
     if (option_rv == -1) break;