From: Akihiko Odaki <akihiko.odaki@daynix.com>
To: Viktor Prutyanov <viktor.prutyanov@phystech.edu>,
Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Akihiko Odaki <akihiko.odaki@daynix.com>
Subject: [PATCH v3 06/19] contrib/elf2dmp: Fix error reporting style in download.c
Date: Wed, 06 Mar 2024 15:12:12 +0900 [thread overview]
Message-ID: <20240306-elf2dmp-v3-6-d74e6c3da49c@daynix.com> (raw)
In-Reply-To: <20240306-elf2dmp-v3-0-d74e6c3da49c@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>
---
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 5c274925f7aa..f65adb5d0894 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 902dc04ffa5c..21306b3fd4c4 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 09af39422f1e..d295fd92be2f 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.44.0
next prev parent reply other threads:[~2024-03-06 6:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-06 6:12 [PATCH v3 00/19] contrib/elf2dmp: Improve robustness Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 01/19] contrib/elf2dmp: Remove unnecessary err flags Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 02/19] contrib/elf2dmp: Assume error by default Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 03/19] contrib/elf2dmp: Continue even contexts are lacking Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 04/19] contrib/elf2dmp: Change pa_space_create() signature Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 05/19] contrib/elf2dmp: Fix error reporting style in addrspace.c Akihiko Odaki
2024-03-06 6:12 ` Akihiko Odaki [this message]
2024-03-06 6:12 ` [PATCH v3 07/19] contrib/elf2dmp: Fix error reporting style in pdb.c Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 08/19] contrib/elf2dmp: Fix error reporting style in qemu_elf.c Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 09/19] contrib/elf2dmp: Fix error reporting style in main.c Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 10/19] contrib/elf2dmp: Always check for PA resolution failure Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 11/19] contrib/elf2dmp: Always destroy PA space Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 12/19] contrib/elf2dmp: Ensure segment fits in file Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 13/19] contrib/elf2dmp: Use lduw_le_p() to read PDB Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 14/19] contrib/elf2dmp: Use rol64() to decode Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 15/19] MAINTAINERS: Add Akihiko Odaki as a elf2dmp reviewer Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 16/19] contrib/elf2dmp: Build only for little endian host Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 17/19] contrib/elf2dmp: Use GPtrArray Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 18/19] contrib/elf2dmp: Clamp QEMU note to file size Akihiko Odaki
2024-03-06 6:12 ` [PATCH v3 19/19] contrib/elf2dmp: Ensure phdrs fit in file Akihiko Odaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240306-elf2dmp-v3-6-d74e6c3da49c@daynix.com \
--to=akihiko.odaki@daynix.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=viktor.prutyanov@phystech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).