- Negative/positive errno mixup caused duplicates not to be detected properly.
Now we get a warning about some duplicate entries in our own catalogs...
- Errors in update_catalog would be ignored, but they should not be.
const char *payload) {
ssize_t offset;
const char *payload) {
ssize_t offset;
+ _cleanup_free_ CatalogItem *i = NULL;
i->offset = htole64((uint64_t) offset);
r = hashmap_put(h, i, i);
i->offset = htole64((uint64_t) offset);
r = hashmap_put(h, i, i);
log_warning("Duplicate entry for " SD_ID128_FORMAT_STR ".%s, ignoring.",
SD_ID128_FORMAT_VAL(id), language ? language : "C");
log_warning("Duplicate entry for " SD_ID128_FORMAT_STR ".%s, ignoring.",
SD_ID128_FORMAT_VAL(id), language ? language : "C");
+ } else if (r < 0)
+ return r;
int catalog_update(const char* database, const char* root, const char* const* dirs) {
_cleanup_strv_free_ char **files = NULL;
char **f;
int catalog_update(const char* database, const char* root, const char* const* dirs) {
_cleanup_strv_free_ char **files = NULL;
char **f;
struct strbuf *sb = NULL;
struct strbuf *sb = NULL;
+ _cleanup_hashmap_free_free_ Hashmap *h = NULL;
_cleanup_free_ CatalogItem *items = NULL;
CatalogItem *i;
Iterator j;
_cleanup_free_ CatalogItem *items = NULL;
CatalogItem *i;
Iterator j;
}
STRV_FOREACH(f, files) {
}
STRV_FOREACH(f, files) {
- log_debug("reading file '%s'", *f);
- catalog_import_file(h, sb, *f);
+ log_debug("Reading file '%s'", *f);
+ r = catalog_import_file(h, sb, *f);
+ if (r < 0) {
+ log_error("Failed to import file '%s': %s.",
+ *f, strerror(-r));
+ goto finish;
+ }
}
if (hashmap_size(h) <= 0) {
log_info("No items in catalog.");
}
if (hashmap_size(h) <= 0) {
log_info("No items in catalog.");
goto finish;
} else
log_debug("Found %u items in catalog.", hashmap_size(h));
goto finish;
} else
log_debug("Found %u items in catalog.", hashmap_size(h));
log_debug("%s: wrote %u items, with %zu bytes of strings, %ld total size.",
database, n, sb->len, r);
log_debug("%s: wrote %u items, with %zu bytes of strings, %ld total size.",
database, n, sb->len, r);
- if (h)
- hashmap_free_free(h);
if (sb)
strbuf_cleanup(sb);
if (sb)
strbuf_cleanup(sb);
setlocale(LC_ALL, "de_DE.UTF-8");
setlocale(LC_ALL, "de_DE.UTF-8");
- log_set_max_level(LOG_DEBUG);
+ log_parse_environment();
+ log_open();
test_catalog_file_lang();
test_catalog_file_lang();