if ((new_meta = meta_data_create()) == NULL) {
ERROR("Target `set': failed to create replacement metadata.");
- return (-ENOMEM);
+ return -ENOMEM;
}
- meta_entries = meta_data_toc(data->meta, &meta_toc);
- for (int i = 0; i < meta_entries; i++) {
+ int status = meta_data_toc(data->meta, &meta_toc);
+ if (status < 0) {
+ ERROR("Target `set': meta_data_toc failed with status %d.", status);
+ return status;
+ }
+ size_t meta_entries = (size_t)status;
+
+ for (size_t i = 0; i < meta_entries; i++) {
const char *key = meta_toc[i];
char *string;
int status;
if (status) {
ERROR("Target `set': Unable to get replacement metadata value `%s'.",
key);
- strarray_free(meta_toc, (size_t)meta_entries);
+ strarray_free(meta_toc, meta_entries);
meta_data_destroy(new_meta);
- return (status);
+ return status;
}
ts_subst(temp, sizeof(temp), string, &orig);
status = meta_data_add_string(new_meta, key, temp);
if (status) {
ERROR("Target `set': Unable to set metadata value `%s'.", key);
- strarray_free(meta_toc, (size_t)meta_entries);
+ strarray_free(meta_toc, meta_entries);
meta_data_destroy(new_meta);
- return (status);
+ return status;
}
}