]> git.ipfire.org Git - location/debian/libloc.git/blobdiff - src/test-country.c
Update upstream source from tag 'upstream/0.9.15'
[location/debian/libloc.git] / src / test-country.c
index c6aff49eb14f1c514adfa4091e85607352ed373a..f9db204c2a6183dc80d575ad5f727f2f2b199def 100644 (file)
@@ -124,13 +124,13 @@ int main(int argc, char** argv) {
 
        FILE* f = tmpfile();
        if (!f) {
-               fprintf(stderr, "Could not open file for writing: %s\n", strerror(errno));
+               fprintf(stderr, "Could not open file for writing: %m\n");
                exit(EXIT_FAILURE);
        }
 
        err = loc_writer_write(writer, f, LOC_DATABASE_VERSION_UNSET);
        if (err) {
-               fprintf(stderr, "Could not write database: %s\n", strerror(-err));
+               fprintf(stderr, "Could not write database: %m\n");
                exit(EXIT_FAILURE);
        }
        loc_writer_unref(writer);
@@ -139,13 +139,13 @@ int main(int argc, char** argv) {
        struct loc_database* db;
        err = loc_database_new(ctx, &db, f);
        if (err) {
-               fprintf(stderr, "Could not open database: %s\n", strerror(-err));
+               fprintf(stderr, "Could not open database: %m\n");
                exit(EXIT_FAILURE);
        }
 
        // Lookup an address in the subnet
        err = loc_database_get_country(db, &country, "YY");
-       if (err) {
+       if (err || !country) {
                fprintf(stderr, "Could not find country: YY\n");
                exit(EXIT_FAILURE);
        }