common: remove json_stream_log_suppress
The function is tiny and was only used in one location. And that one location was leaking memory. Detected by ASan: ==2637667==ERROR: LeakSanitizer: detected memory leaks Direct leak of 7 byte(s) in 1 object(s) allocated from: #0 0x4cd758 in __interceptor_strdup #1 0x64c70c in json_stream_log_suppress_for_cmd lightning/lightningd/jsonrpc.c:597:31 #2 0x68a630 in json_getlog lightning/lightningd/log.c:974:2 ... SUMMARY: AddressSanitizer: 7 byte(s) leaked in 1 allocation(s).
This commit is contained in:
parent
c05d7e4f78
commit
a5afb4f811
|
@ -95,13 +95,6 @@ static bool json_stream_still_writing(const struct json_stream *js)
|
|||
return js->writer != NULL;
|
||||
}
|
||||
|
||||
void json_stream_log_suppress(struct json_stream *js, const char *cmd_name)
|
||||
{
|
||||
/* Really shouldn't be used for anything else */
|
||||
assert(streq(cmd_name, "getlog"));
|
||||
js->log = NULL;
|
||||
}
|
||||
|
||||
void json_stream_append(struct json_stream *js,
|
||||
const char *str, size_t len)
|
||||
{
|
||||
|
|
|
@ -97,9 +97,6 @@ const char *json_stream_detach_filter(const tal_t *ctx, struct json_stream *js);
|
|||
*/
|
||||
void json_stream_close(struct json_stream *js, struct command *writer);
|
||||
|
||||
/* For low-level JSON stream access: */
|
||||
void json_stream_log_suppress(struct json_stream *js, const char *cmd_name);
|
||||
|
||||
/* '"fieldname" : [ ' or '[ ' if fieldname is NULL */
|
||||
void json_array_start(struct json_stream *js, const char *fieldname);
|
||||
/* '"fieldname" : { ' or '{ ' if fieldname is NULL */
|
||||
|
|
|
@ -594,8 +594,10 @@ void json_stream_log_suppress_for_cmd(struct json_stream *js,
|
|||
const char *nm = cmd->json_cmd->name;
|
||||
const char *s = tal_fmt(tmpctx, "Suppressing logging of %s command", nm);
|
||||
log_io(cmd->jcon->log, LOG_IO_OUT, NULL, s, NULL, 0);
|
||||
json_stream_log_suppress(js, strdup(nm));
|
||||
|
||||
/* Really shouldn't be used for anything else */
|
||||
assert(streq(nm, "getlog"));
|
||||
js->log = NULL;
|
||||
}
|
||||
|
||||
static struct json_stream *json_start(struct command *cmd)
|
||||
|
|
Loading…
Reference in New Issue