[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/20] contrib/elf2dmp: Fix error reporting style in download.c
From: |
Peter Maydell |
Subject: |
[PULL 07/20] contrib/elf2dmp: Fix error reporting style in download.c |
Date: |
Mon, 11 Mar 2024 19:12:28 +0000 |
From: Akihiko Odaki <akihiko.odaki@daynix.com>
include/qapi/error.h says:
> We recommend
> * bool-valued functions return true on success / false on failure,
> ...
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Tested-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20240307-elf2dmp-v4-6-4f324ad4d99d@daynix.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
contrib/elf2dmp/download.h | 2 +-
contrib/elf2dmp/download.c | 10 +++++-----
contrib/elf2dmp/main.c | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/contrib/elf2dmp/download.h b/contrib/elf2dmp/download.h
index 5c274925f7a..f65adb5d089 100644
--- a/contrib/elf2dmp/download.h
+++ b/contrib/elf2dmp/download.h
@@ -8,6 +8,6 @@
#ifndef DOWNLOAD_H
#define DOWNLOAD_H
-int download_url(const char *name, const char *url);
+bool download_url(const char *name, const char *url);
#endif /* DOWNLOAD_H */
diff --git a/contrib/elf2dmp/download.c b/contrib/elf2dmp/download.c
index 902dc04ffa5..21306b3fd4c 100644
--- a/contrib/elf2dmp/download.c
+++ b/contrib/elf2dmp/download.c
@@ -9,14 +9,14 @@
#include <curl/curl.h>
#include "download.h"
-int download_url(const char *name, const char *url)
+bool download_url(const char *name, const char *url)
{
- int err = 1;
+ bool success = false;
FILE *file;
CURL *curl = curl_easy_init();
if (!curl) {
- return 1;
+ return false;
}
file = fopen(name, "wb");
@@ -33,11 +33,11 @@ int download_url(const char *name, const char *url)
unlink(name);
fclose(file);
} else {
- err = fclose(file);
+ success = !fclose(file);
}
out_curl:
curl_easy_cleanup(curl);
- return err;
+ return success;
}
diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c
index 09af39422f1..d295fd92be2 100644
--- a/contrib/elf2dmp/main.c
+++ b/contrib/elf2dmp/main.c
@@ -591,7 +591,7 @@ int main(int argc, char *argv[])
sprintf(pdb_url, "%s%s/%s/%s", SYM_URL_BASE, PDB_NAME, pdb_hash, PDB_NAME);
printf("PDB URL is %s\n", pdb_url);
- if (download_url(PDB_NAME, pdb_url)) {
+ if (!download_url(PDB_NAME, pdb_url)) {
eprintf("Failed to download PDB file\n");
goto out_ps;
}
--
2.34.1
- Re: [PULL 00/20] target-arm queue, (continued)
- Re: [PULL 00/20] target-arm queue, Peter Maydell, 2024/03/05
- [PULL 00/20] target-arm queue, Peter Maydell, 2024/03/11
- [PULL 03/20] contrib/elf2dmp: Assume error by default, Peter Maydell, 2024/03/11
- [PULL 08/20] contrib/elf2dmp: Fix error reporting style in pdb.c, Peter Maydell, 2024/03/11
- [PULL 15/20] contrib/elf2dmp: Use rol64() to decode, Peter Maydell, 2024/03/11
- [PULL 12/20] contrib/elf2dmp: Always destroy PA space, Peter Maydell, 2024/03/11
- [PULL 18/20] contrib/elf2dmp: Clamp QEMU note to file size, Peter Maydell, 2024/03/11
- [PULL 11/20] contrib/elf2dmp: Always check for PA resolution failure, Peter Maydell, 2024/03/11
- [PULL 20/20] docs: update copyright date to the year 2024, Peter Maydell, 2024/03/11
- [PULL 01/20] hw/arm: Deprecate various old Arm machine types, Peter Maydell, 2024/03/11
- [PULL 07/20] contrib/elf2dmp: Fix error reporting style in download.c,
Peter Maydell <=
- [PULL 04/20] contrib/elf2dmp: Continue even contexts are lacking, Peter Maydell, 2024/03/11
- [PULL 02/20] contrib/elf2dmp: Remove unnecessary err flags, Peter Maydell, 2024/03/11
- [PULL 14/20] contrib/elf2dmp: Use lduw_le_p() to read PDB, Peter Maydell, 2024/03/11
- [PULL 13/20] contrib/elf2dmp: Ensure segment fits in file, Peter Maydell, 2024/03/11
- [PULL 09/20] contrib/elf2dmp: Fix error reporting style in qemu_elf.c, Peter Maydell, 2024/03/11
- [PULL 05/20] contrib/elf2dmp: Change pa_space_create() signature, Peter Maydell, 2024/03/11
- [PULL 06/20] contrib/elf2dmp: Fix error reporting style in addrspace.c, Peter Maydell, 2024/03/11
- [PULL 17/20] contrib/elf2dmp: Use GPtrArray, Peter Maydell, 2024/03/11
- [PULL 10/20] contrib/elf2dmp: Fix error reporting style in main.c, Peter Maydell, 2024/03/11
- [PULL 16/20] MAINTAINERS: Add Akihiko Odaki as a elf2dmp reviewer, Peter Maydell, 2024/03/11