pbs block driver: improve data type for aid member
On ARM, gcc warns (-Werror=type-limits) that it will always be false for the if statement. This is because here s->aid is defined as char, while proxmox_restore_open_image() returns an int. This is probably because chars are treated as unsigned on arm arch but signed on x86 arch: https://developer.arm.com/documentation/den0013/d/Porting/Miscellaneous-C-porting-issues/unsigned-char-and-signed-char Make aid an explicit uint8_t, because that is the type for functions taking the aid as a parameter, e.g. proxmox_restore_get_image_length(). Signed-off-by: Jing Luo <jing@jing.rocks> [FE: slightly improve commit message] Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
bb80c7f323
commit
51df4937bf
@ -15,11 +15,11 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
|||||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||||
---
|
---
|
||||||
block/meson.build | 2 +
|
block/meson.build | 2 +
|
||||||
block/pbs.c | 307 +++++++++++++++++++++++++++++++++++++++++++
|
block/pbs.c | 310 +++++++++++++++++++++++++++++++++++++++++++
|
||||||
meson.build | 2 +-
|
meson.build | 2 +-
|
||||||
qapi/block-core.json | 29 ++++
|
qapi/block-core.json | 29 ++++
|
||||||
qapi/pragma.json | 1 +
|
qapi/pragma.json | 1 +
|
||||||
5 files changed, 340 insertions(+), 1 deletion(-)
|
5 files changed, 343 insertions(+), 1 deletion(-)
|
||||||
create mode 100644 block/pbs.c
|
create mode 100644 block/pbs.c
|
||||||
|
|
||||||
diff --git a/block/meson.build b/block/meson.build
|
diff --git a/block/meson.build b/block/meson.build
|
||||||
@ -37,10 +37,10 @@ index 6bba803f94..1945e04eeb 100644
|
|||||||
system_ss.add(files('block-ram-registrar.c'))
|
system_ss.add(files('block-ram-registrar.c'))
|
||||||
diff --git a/block/pbs.c b/block/pbs.c
|
diff --git a/block/pbs.c b/block/pbs.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000..dd72356bd3
|
index 0000000000..9112d4dfe6
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/block/pbs.c
|
+++ b/block/pbs.c
|
||||||
@@ -0,0 +1,307 @@
|
@@ -0,0 +1,310 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Proxmox Backup Server read-only block driver
|
+ * Proxmox Backup Server read-only block driver
|
||||||
+ */
|
+ */
|
||||||
@ -68,7 +68,7 @@ index 0000000000..dd72356bd3
|
|||||||
+
|
+
|
||||||
+typedef struct {
|
+typedef struct {
|
||||||
+ ProxmoxRestoreHandle *conn;
|
+ ProxmoxRestoreHandle *conn;
|
||||||
+ char aid;
|
+ uint8_t aid;
|
||||||
+ int64_t length;
|
+ int64_t length;
|
||||||
+
|
+
|
||||||
+ char *repository;
|
+ char *repository;
|
||||||
@ -201,12 +201,15 @@ index 0000000000..dd72356bd3
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /* acquire handle and length */
|
+ /* acquire handle and length */
|
||||||
+ s->aid = proxmox_restore_open_image(s->conn, s->archive, &pbs_error);
|
+ ret = proxmox_restore_open_image(s->conn, s->archive, &pbs_error);
|
||||||
+ if (s->aid < 0) {
|
+ if (ret < 0 || ret > UINT8_MAX) {
|
||||||
+ if (pbs_error && errp) error_setg(errp, "PBS open_image failed: %s", pbs_error);
|
+ if (pbs_error && errp) error_setg(errp, "PBS open_image failed: %s", pbs_error);
|
||||||
+ if (pbs_error) proxmox_backup_free_error(pbs_error);
|
+ if (pbs_error) proxmox_backup_free_error(pbs_error);
|
||||||
+ return -ENODEV;
|
+ return -ENODEV;
|
||||||
|
+ } else {
|
||||||
|
+ s->aid = ret;
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ s->length = proxmox_restore_get_image_length(s->conn, s->aid, &pbs_error);
|
+ s->length = proxmox_restore_get_image_length(s->conn, s->aid, &pbs_error);
|
||||||
+ if (s->length < 0) {
|
+ if (s->length < 0) {
|
||||||
+ if (pbs_error && errp) error_setg(errp, "PBS get_image_length failed: %s", pbs_error);
|
+ if (pbs_error && errp) error_setg(errp, "PBS get_image_length failed: %s", pbs_error);
|
||||||
|
Loading…
Reference in New Issue
Block a user