From: SangYoun Kwak Date: Mon, 22 Jul 2024 02:47:56 +0000 (+0900) Subject: copy-blockdev: Modify to use strerror_r instead of %m X-Git-Tag: accepted/tizen/unified/20240723.034810^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ec0f5d93bc20b35de59471f007ca60d016275c98;p=platform%2Fcore%2Fsystem%2Fupgrade.git copy-blockdev: Modify to use strerror_r instead of %m '%m' formatting is an glibc extension, it can be not-supported according to the build environment. It is not supported in VD environment, so it is replaced with strerror_r. Change-Id: I3bb8b458b3b7f47e36d9e6c22d9b03e946aab30f Signed-off-by: SangYoun Kwak --- diff --git a/src/copy-blockdev/lib.c b/src/copy-blockdev/lib.c index f5b646d..04b7115 100644 --- a/src/copy-blockdev/lib.c +++ b/src/copy-blockdev/lib.c @@ -252,6 +252,8 @@ int copy_and_update_progress(struct params_t *params) { long long range = params->progress_to - params->progress_from; size_t count = params->partsize; double percentage; + int ret = 0; + char err_str[256] = { 0 }; __attribute__((cleanup(fd_cleanup))) int fd_src = open(params->src, O_RDONLY); @@ -267,13 +269,17 @@ int copy_and_update_progress(struct params_t *params) { return ERR_DST_OPEN; } - errno = posix_fadvise(fd_src, 0, 0, POSIX_FADV_SEQUENTIAL); - if (errno != 0) - fprintf(stderr, "Cannot call posix_fadvise for src: %m\n"); + ret = posix_fadvise(fd_src, 0, 0, POSIX_FADV_SEQUENTIAL); + if (ret != 0) { + strerror_r(ret, err_str, sizeof(err_str)); + fprintf(stderr, "Cannot call posix_fadvise for src: %s(%d)\n", err_str, ret); + } - errno = posix_fadvise(fd_dst, 0, 0, POSIX_FADV_SEQUENTIAL); - if (errno != 0) - fprintf(stderr, "Cannot call posix_fadvise for dst: %m\n"); + ret = posix_fadvise(fd_dst, 0, 0, POSIX_FADV_SEQUENTIAL); + if (ret != 0) { + strerror_r(ret, err_str, sizeof(err_str)); + fprintf(stderr, "Cannot call posix_fadvise for dst: %s(%d)\n", err_str, ret); + } fprintf(stderr, "%s -> %s: %3d%% (%3d%% overall)", params->src, params->dst, 0, (int) params->progress_from);