At Mon, 30 Jul 2012 13:07:21 +0800, levin li wrote: > > From: levin li <xingke.lwp at taobao.com> > > > Signed-off-by: levin li <xingke.lwp at taobao.com> > --- > collie/node.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ > include/internal_proto.h | 1 + > 2 files changed, 46 insertions(+), 0 deletions(-) > > diff --git a/collie/node.c b/collie/node.c > index df841a0..af0b4f0 100644 > --- a/collie/node.c > +++ b/collie/node.c > @@ -139,6 +139,49 @@ static int node_recovery(int argc, char **argv) > return EXIT_SUCCESS; > } > > +static int node_cache(int argc, char **argv) > +{ > + char *p; > + int fd, ret, cache_size; > + unsigned int wlen, rlen = 0; > + struct sd_req hdr; > + struct sd_rsp *rsp = (struct sd_rsp *)&hdr; > + > + cache_size = strtol(argv[optind++], &p, 10); > + if (argv[optind] == p || cache_size < 0) { optind is incremented in the previous line. > + fprintf(stderr, "Invalid cache size %d\n", cache_size); You should print the input string (argv[optind]) because if no conversion happens, strtol returns zero. Thanks, Kazutaka |