chiark / gitweb /
use more appropriate alternatives to malloc()
[elogind.git] / extras / volume_id / lib / volume_id.c
index 9b7d91d11da786ac2885f6628dd185e4870b053e..8f22509ca6be6ab718780dda3e4c428c4cbc0a9a 100644 (file)
@@ -83,6 +83,7 @@ static const struct prober prober_filesystem[] = {
        { volume_id_probe_squashfs, { "squashfs", } },
        { volume_id_probe_netware, { "netware", } },
        { volume_id_probe_oracleasm, { "oracleasm", } },
+       { volume_id_probe_btrfs, { "btrfs", } },
 };
 
 /* the user can overwrite this log function */
@@ -366,8 +367,7 @@ int volume_id_probe_raid(struct volume_id *id, uint64_t off, uint64_t size)
        if (!device_is_readable(id, off))
                return -1;
 
-       info("probing at offset 0x%llx, size 0x%llx\n",
-           (unsigned long long) off, (unsigned long long) size);
+       info("probing at offset 0x%" PRIx64 ", size 0x%" PRIx64 "\n", off, size);
 
        for (i = 0; i < ARRAY_SIZE(prober_raid); i++)
                if (prober_raid[i].prober(id, off, size) == 0)
@@ -400,8 +400,7 @@ int volume_id_probe_filesystem(struct volume_id *id, uint64_t off, uint64_t size
        if (!device_is_readable(id, off))
                return -1;
 
-       info("probing at offset 0x%llx, size 0x%llx\n",
-           (unsigned long long) off, (unsigned long long) size);
+       info("probing at offset 0x%" PRIx64 ", size 0x%" PRIx64 "\n", off, size);
 
        for (i = 0; i < ARRAY_SIZE(prober_filesystem); i++)
                if (prober_filesystem[i].prober(id, off, size) == 0)
@@ -484,10 +483,9 @@ struct volume_id *volume_id_open_fd(int fd)
 {
        struct volume_id *id;
 
-       id = malloc(sizeof(struct volume_id));
+       id = calloc(1, sizeof(struct volume_id));
        if (id == NULL)
                return NULL;
-       memset(id, 0x00, sizeof(struct volume_id));
 
        id->fd = fd;