From 77abfebefc181d1e459e5c8506c99d791acbce25 Mon Sep 17 00:00:00 2001 From: xhe Date: Thu, 24 Dec 2020 20:13:57 +0800 Subject: [PATCH] address comment Signed-off-by: xhe --- src/networking.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/networking.c b/src/networking.c index 0760a4669..c44976d12 100644 --- a/src/networking.c +++ b/src/networking.c @@ -2763,15 +2763,16 @@ void helloCommand(client *c) { long long ver = 0; int next_arg = 1; - if (c->argc >= 2 && getLongLongFromObject(c->argv[next_arg++],&ver) == C_OK && - (ver < 2 || ver > 3)) { - addReplyError(c,"-NOPROTO unsupported protocol version"); - return; - } + if (c->argc >= 2) { + if (getLongLongFromObjectOrReply(c, c->argv[next_arg++], &ver, + "The second argument should the protocol version if provided") != C_OK) { + return; + } - if (!ver && next_arg < c->argc) { - addReplyError(c,"Need to provide an protocol version for other arguments"); - return; + if (ver < 2 || ver > 3) { + addReplyError(c,"-NOPROTO unsupported protocol version"); + return; + } } for (int j = next_arg; j < c->argc; j++) {