websrv useless if(), then string copy

This commit is contained in:
Laurent THOMAS
2025-04-04 16:05:38 +02:00
committed by Robert Schmidt
parent 990414572a
commit f9835e996a
+1 -6
View File
@@ -622,12 +622,9 @@ int websrv_callback_get_softmodemcmd(const struct _u_request *request, struct _u
acmd = json_pack("{s:s,s:s}", "name", modulestruct->cmd[j].cmdname, "confirm", confstr); acmd = json_pack("{s:s,s:s}", "name", modulestruct->cmd[j].cmdname, "confirm", confstr);
} else if (modulestruct->cmd[j].cmdflags & TELNETSRV_CMDFLAG_NEEDPARAM) { } else if (modulestruct->cmd[j].cmdflags & TELNETSRV_CMDFLAG_NEEDPARAM) {
char *question[] = {NULL, NULL}; char *question[] = {NULL, NULL};
char *helpcp = NULL;
json_t *jQ1=NULL, *jQ2=NULL; json_t *jQ1=NULL, *jQ2=NULL;
json_t *jQs = json_array(); json_t *jQs = json_array();
if (modulestruct->cmd[j].helpstr != NULL) { int ns = sscanf(modulestruct->cmd[j].helpstr, "<%m[^<>]> <%m[^<>]>", &question[0], &question[1]);
helpcp = strdup(modulestruct->cmd[j].helpstr);
int ns=sscanf(helpcp,"<%m[^<>]> <%m[^<>]>",&question[0],&question[1]);
if (ns == 0) { if (ns == 0) {
LOG_W(UTIL, "[websrv] Cannot find parameters for command %s %s\n", modulestruct->module, modulestruct->cmd[j].cmdname); LOG_W(UTIL, "[websrv] Cannot find parameters for command %s %s\n", modulestruct->module, modulestruct->cmd[j].cmdname);
continue; continue;
@@ -638,9 +635,7 @@ int websrv_callback_get_softmodemcmd(const struct _u_request *request, struct _u
jQ2 = json_pack("{s:s,s:s,s:s}", "display", (question[1] == NULL) ? "" : question[1], "pname", "P1", "type", "string"); jQ2 = json_pack("{s:s,s:s,s:s}", "display", (question[1] == NULL) ? "" : question[1], "pname", "P1", "type", "string");
json_array_append_new(jQs, jQ2); json_array_append_new(jQs, jQ2);
} }
}
acmd = json_pack("{s:s,s:o}", "name", modulestruct->cmd[j].cmdname, "question", jQs); acmd = json_pack("{s:s,s:o}", "name", modulestruct->cmd[j].cmdname, "question", jQs);
free(helpcp);
free(question[0]); free(question[0]);
free(question[1]); free(question[1]);
} else { } else {