Skip to content

Commit

Permalink
contrib/elf2dmp: Fix error reporting style in download.c
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
akihikodaki authored and pm215 committed Mar 11, 2024
1 parent a15f974 commit 1b806c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions contrib/elf2dmp/download.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion contrib/elf2dmp/download.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 1 addition & 1 deletion contrib/elf2dmp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1b806c3

Please sign in to comment.