chiark / gitweb /
volume_id: fix error handling with failing read()
[elogind.git] / extras / volume_id / volume_id / util.c
index 62b96a3..d1271a8 100644 (file)
@@ -197,7 +197,7 @@ set:
 
 uint8_t *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
 {
-       size_t buf_len;
+       ssize_t buf_len;
 
        dbg("get buffer off 0x%llx(%llu), len 0x%zx", (unsigned long long) off, (unsigned long long) off, len);
        /* check if requested area fits in superblock buffer */
@@ -224,7 +224,7 @@ uint8_t *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
                        }
                        dbg("got 0x%zx (%zi) bytes", buf_len, buf_len);
                        id->sbbuf_len = buf_len;
-                       if (buf_len < off + len) {
+                       if ((size_t)buf_len < off + len) {
                                dbg("requested 0x%zx bytes, got only 0x%zx bytes", len, buf_len);
                                return NULL;
                        }
@@ -261,7 +261,7 @@ uint8_t *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
                        dbg("got 0x%zx (%zi) bytes", buf_len, buf_len);
                        id->seekbuf_off = off;
                        id->seekbuf_len = buf_len;
-                       if (buf_len < len) {
+                       if ((size_t)buf_len < len) {
                                dbg("requested 0x%zx bytes, got only 0x%zx bytes", len, buf_len);
                                return NULL;
                        }