mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 11:59:16 +01:00
plugins: fix compile warning with some gcc versions and -Og
Indeed, we can fall through this if it's not a valid enum value. gcc-12 (Ubuntu 12.2.0-17ubuntu1) 12.2.0 ``` In file included from plugins/commando.c:10: ccan/ccan/tal/str/str.h: In function ‘rune_altern_to_english’: ccan/ccan/tal/str/str.h:43:9: error: ‘cond_str’ may be used uninitialized [-Werror=maybe-uninitialized] 43 | tal_fmt_(ctx, TAL_LABEL(char, "[]"), __VA_ARGS__) | ^~~~~~~~ plugins/commando.c:97:21: note: ‘cond_str’ was declared here 97 | const char *cond_str; | ^~~~~~~~ cc1: all warnings being treated as errors ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
028dcb875b
commit
9239278cdd
1 changed files with 18 additions and 20 deletions
|
@ -193,43 +193,41 @@ static bool is_unique_id(struct rune_restr **restrs, unsigned int index)
|
|||
return streq(restrs[index]->alterns[0]->fieldname, "");
|
||||
}
|
||||
|
||||
static char *fmt_cond(const tal_t *ctx,
|
||||
const struct rune_altern *alt,
|
||||
const char *cond_str)
|
||||
{
|
||||
return tal_fmt(ctx, "%s %s %s", alt->fieldname, cond_str, alt->value);
|
||||
}
|
||||
|
||||
static char *rune_altern_to_english(const tal_t *ctx, const struct rune_altern *alt)
|
||||
{
|
||||
const char *cond_str;
|
||||
switch (alt->condition) {
|
||||
case RUNE_COND_IF_MISSING:
|
||||
return tal_strcat(ctx, alt->fieldname, " is missing");
|
||||
case RUNE_COND_EQUAL:
|
||||
cond_str = "equal to";
|
||||
break;
|
||||
return fmt_cond(ctx, alt, "equal to");
|
||||
case RUNE_COND_NOT_EQUAL:
|
||||
cond_str = "unequal to";
|
||||
break;
|
||||
return fmt_cond(ctx, alt, "unequal to");
|
||||
case RUNE_COND_BEGINS:
|
||||
cond_str = "starts with";
|
||||
break;
|
||||
return fmt_cond(ctx, alt, "starts with");
|
||||
case RUNE_COND_ENDS:
|
||||
cond_str = "ends with";
|
||||
break;
|
||||
return fmt_cond(ctx, alt, "ends with");
|
||||
case RUNE_COND_CONTAINS:
|
||||
cond_str = "contains";
|
||||
break;
|
||||
return fmt_cond(ctx, alt, "contains");
|
||||
case RUNE_COND_INT_LESS:
|
||||
cond_str = "<";
|
||||
break;
|
||||
return fmt_cond(ctx, alt, "<");
|
||||
case RUNE_COND_INT_GREATER:
|
||||
cond_str = ">";
|
||||
break;
|
||||
return fmt_cond(ctx, alt, ">");
|
||||
case RUNE_COND_LEXO_BEFORE:
|
||||
cond_str = "sorts before";
|
||||
break;
|
||||
return fmt_cond(ctx, alt, "sorts before");
|
||||
case RUNE_COND_LEXO_AFTER:
|
||||
cond_str = "sorts after";
|
||||
break;
|
||||
return fmt_cond(ctx, alt, "sorts after");
|
||||
case RUNE_COND_COMMENT:
|
||||
return tal_fmt(ctx, "comment: %s %s", alt->fieldname, alt->value);
|
||||
}
|
||||
return tal_fmt(ctx, "%s %s %s", alt->fieldname, cond_str, alt->value);
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
static char *json_add_alternative(const tal_t *ctx,
|
||||
|
|
Loading…
Add table
Reference in a new issue