From: Mark Atwood Date: Fri, 21 Sep 2007 15:14:04 +0000 (-0700) Subject: bugfixes and formating fixes X-Git-Tag: 0.2~10^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=58cca49d065f6c53386d7e89c8e515f8b4e69485;p=awesomized%2Flibmemcached bugfixes and formating fixes --- diff --git a/src/memcat.c b/src/memcat.c index 1a6e3898..ed540abb 100644 --- a/src/memcat.c +++ b/src/memcat.c @@ -19,7 +19,7 @@ int main(int argc, char *argv[]) memcached_st *memc; char *string; size_t string_length; - uint16_t flags; + uint16_t flags; memcached_return rc; memc= memcached_init(NULL); @@ -37,13 +37,13 @@ int main(int argc, char *argv[]) if (opt_displayflag) { if (opt_verbose) - printf("key: %.*s\nflags: ", argv[optind]); - printf("%d\n", flags); + printf("key: %s\nflags: ", argv[optind]); + printf("%x\n", flags); } else { if (opt_verbose) - printf("key: %.*s\nflags: %d\nlength: %d\nvalue: ", + printf("key: %s\nflags: %x\nlength: %zu\nvalue: ", argv[optind], flags, string_length); printf("%.*s\n", string_length, string); free(string); @@ -65,10 +65,10 @@ int main(int argc, char *argv[]) void options_parse(int argc, char *argv[]) { - int option_index = 0; + int option_index= 0; int option_rv; - static struct option long_options[] = + static struct option long_options[]= { {"version", no_argument, NULL, OPT_VERSION}, {"help", no_argument, NULL, OPT_HELP}, @@ -81,9 +81,10 @@ void options_parse(int argc, char *argv[]) while (1) { - option_rv = getopt_long(argc, argv, "Vhvds:", long_options, &option_index); + option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; - switch (option_rv) { + switch (option_rv) + { case 0: break; case OPT_VERSION: /* --version or -V */ diff --git a/src/memcp.c b/src/memcp.c index fc396ff1..3a76049a 100644 --- a/src/memcp.c +++ b/src/memcp.c @@ -40,7 +40,8 @@ int main(int argc, char *argv[]) char *ptr; fd= open(argv[optind], O_RDONLY); - if (fd < 0) { + if (fd < 0) + { fprintf(stderr, "memcp: %s: %s\n", argv[optind], strerror(errno)); optind++; continue; @@ -48,7 +49,8 @@ int main(int argc, char *argv[]) (void)fstat(fd, &sbuf); mptr= mmap(NULL, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (mptr == MAP_FAILED) { + if (mptr == MAP_FAILED) + { fprintf(stderr, "memcp: %s: %s\n", argv[optind], strerror(errno)); close(fd); optind++; @@ -61,10 +63,11 @@ int main(int argc, char *argv[]) else ptr= argv[optind]; - if (opt_verbose) { - static char *opstr[] = { "set", "add", "replace" }; - printf("op: %s\nsource file: %s\nlength: %d\n" - "key: %s\nflags: %d\n expires: %ld\n", + if (opt_verbose) + { + static char *opstr[]= { "set", "add", "replace" }; + printf("op: %s\nsource file: %s\nlength: %zu\n" + "key: %s\nflags: %x\n expires: %ld\n", opstr[opt_replace], argv[optind], sbuf.st_size, ptr, opt_flags, opt_expires); } @@ -84,7 +87,8 @@ int main(int argc, char *argv[]) else abort(); - if (rc != MEMCACHED_SUCCESS) { + if (rc != MEMCACHED_SUCCESS) + { fprintf(stderr, "memcp: %s: memcache error %s\n", ptr, memcached_strerror(memc, rc)); } @@ -97,14 +101,14 @@ int main(int argc, char *argv[]) memcached_deinit(memc); return 0; -}; +} void options_parse(int argc, char *argv[]) { int option_index= 0; int option_rv; - static struct option long_options[] = + static struct option long_options[]= { {"version", no_argument, NULL, OPT_VERSION}, {"help", no_argument, NULL, OPT_HELP}, @@ -125,7 +129,8 @@ void options_parse(int argc, char *argv[]) if (option_rv == -1) break; - switch (option_rv) { + switch (option_rv) + { case 0: break; case OPT_VERSION: /* --version or -V */ @@ -138,7 +143,7 @@ void options_parse(int argc, char *argv[]) opt_servers= optarg; break; case OPT_FLAG: /* --flag */ - opt_flags= (uint16_t)strtol(optarg, (char **)NULL, 10); + opt_flags= (uint16_t)strtol(optarg, (char **)NULL, 16); break; case OPT_EXPIRE: /* --expire */ opt_expires= (time_t)strtol(optarg, (char **)NULL, 10); diff --git a/src/memrm.c b/src/memrm.c index 49172e5a..f49444e8 100644 --- a/src/memrm.c +++ b/src/memrm.c @@ -12,10 +12,10 @@ int main(int argc, char *argv[]) memcached_st *memc; char *string; size_t string_length; - time_t expires = 0; + time_t expires= 0; memcached_return rc; - static struct option long_options[] = + static struct option long_options[]= { {"version", no_argument, NULL, OPT_VERSION}, {"help", no_argument, NULL, OPT_HELP}, @@ -25,14 +25,15 @@ int main(int argc, char *argv[]) {"expire", required_argument, NULL, OPT_EXPIRE}, {0, 0, 0, 0}, }; - int option_index = 0; + int option_index= 0; int option_rv; while (1) { - option_rv = getopt_long(argc, argv, "Vhvds:", long_options, &option_index); + option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; - switch (option_rv) { + switch (option_rv) + { case 0: break; case OPT_VERSION: /* --version or -V */ @@ -44,10 +45,10 @@ int main(int argc, char *argv[]) exit(0); break; case OPT_SERVERS: /* --servers or -s */ - opt_servers = optarg; + opt_servers= optarg; break; case OPT_EXPIRE: /* --expire */ - expires = (time_t)strtol(optarg, (char **)NULL, 10); + expires= (time_t)strtol(optarg, (char **)NULL, 10); break; case '?': /* getopt_long already printed an error message. */ @@ -62,15 +63,14 @@ int main(int argc, char *argv[]) while (optind <= argc) { - if (opt_verbose) { + if (opt_verbose) printf("key: %s\nexpires: %ld\n", argv[optind], expires); - } - rc = memcached_delete(memc, argv[optind], strlen(argv[optind]), expires); - if (rc != MEMCACHED_SUCCESS) { + rc= memcached_delete(memc, argv[optind], strlen(argv[optind]), expires); + + if (rc != MEMCACHED_SUCCESS) fprintf(stderr, "memrm: %s: memcache error %s\n", argv[optind], memcached_strerror(memc, rc)); - } optind++; } @@ -78,4 +78,4 @@ int main(int argc, char *argv[]) memcached_deinit(memc); return 0; -}; +} diff --git a/src/memstat.c b/src/memstat.c index dcfb3af9..e7810200 100644 --- a/src/memstat.c +++ b/src/memstat.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) void options_parse(int argc, char *argv[]) { - static struct option long_options[] = + static struct option long_options[]= { {"version", no_argument, NULL, OPT_VERSION}, {"help", no_argument, NULL, OPT_HELP}, @@ -45,14 +45,15 @@ void options_parse(int argc, char *argv[]) {0, 0, 0, 0}, }; - int option_index = 0; + int option_index= 0; int option_rv; while (1) { - option_rv = getopt_long(argc, argv, "Vhvds:", long_options, &option_index); + option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; - switch (option_rv) { + switch (option_rv) + { case 0: break; case OPT_VERSION: /* --version or -V */ @@ -64,7 +65,7 @@ void options_parse(int argc, char *argv[]) exit(0); break; case OPT_SERVERS: /* --servers or -s */ - opt_servers = optarg; + opt_servers= optarg; break; case '?': /* getopt_long already printed an error message. */