The compiler marks a potential use after free, which the current
implementation won't trigger. The error only occurs when a sigrok
channel is neither logic nor analog.
Address the issue nevertheless, to silence the compiler warning, and to
protect against possible programming errors when a future implementation
should support more channel types.
This was reported by clang's scan-build.
if (!ch->enabled)
continue;
+ s = NULL;
switch (ch->type) {
case SR_CHANNEL_LOGIC:
s = g_strdup_printf("probe%d", ch->index + 1);
index++;
break;
}
- g_key_file_set_string(meta, devgroup, s, ch->name);
- g_free(s);
+ if (s) {
+ g_key_file_set_string(meta, devgroup, s, ch->name);
+ g_free(s);
+ }
}
metabuf = g_key_file_to_data(meta, &metalen, NULL);