From 2fe999fd8b7f8473d941562b8f1c1fd319554403 Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 23 Oct 2020 11:16:22 +0200 Subject: [PATCH] examples/gcoap: Allow PUT/POST with empty payload All access to the respective position in argv is already checked against the argc count, and the online usage documentation already declares the argument as optional (where not accepting it at GET seems obvious enough, but requiring it with POST or PUT does not). Thus, allowing it in the argument count check is the only thing to remain. --- examples/gcoap/gcoap_cli.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/gcoap/gcoap_cli.c b/examples/gcoap/gcoap_cli.c index a14e936a25..c35470885a 100644 --- a/examples/gcoap/gcoap_cli.c +++ b/examples/gcoap/gcoap_cli.c @@ -373,7 +373,8 @@ int gcoap_cli_cmd(int argc, char **argv) if (((argc == apos + 2) && (code_pos == 0)) || /* ping */ ((argc == apos + 3) && (code_pos == 1)) || /* get */ - ((argc == apos + 4) && (code_pos > 1))) { /* post or put */ + ((argc == apos + 3 || + argc == apos + 4) && (code_pos > 1))) { /* post or put */ char *uri = NULL; int uri_len = 0;