From a4d1efddefa2114211d736479dd4813ecc1e8014 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Wed, 7 Nov 2018 12:00:18 +0100 Subject: [PATCH] util: Unify function calling convention to specify destination first This commit adjusts signature of copy_file(), move_file() and dump_file_write_fd() to specify destination first, source second. This in line with rest of codebase. Change-Id: I81285cda73d43ff2428ea5daf7ad27676e51ca8a Signed-off-by: Karol Lewandowski --- src/crash-manager/crash-manager.c | 2 +- src/dump_systemstate/dump_systemstate.c | 2 +- src/shared/util.c | 8 ++++---- src/shared/util.h | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index a02d59c..95cbf8b 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -623,7 +623,7 @@ static int get_sysassert_cs(struct crash_info *cinfo) return -1; } - if (move_file(cinfo->sysassert_cs_path, move_path) < 0) { + if (move_file(move_path, cinfo->sysassert_cs_path) < 0) { _E("Failed to move %s to %s", cinfo->sysassert_cs_path, move_path); return -1; diff --git a/src/dump_systemstate/dump_systemstate.c b/src/dump_systemstate/dump_systemstate.c index fb2ee75..d4c0e40 100644 --- a/src/dump_systemstate/dump_systemstate.c +++ b/src/dump_systemstate/dump_systemstate.c @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) fsync(out_fd); fprintf_fd(out_fd, "\n%s(%s)\n", dump_item[i].title, dump_item[i].path); - ret = dump_file_write_fd((char *)dump_item[i].path, out_fd); + ret = dump_file_write_fd(out_fd, (char *)dump_item[i].path); INFORM_IF_ERROR(ret) } fprintf_fd(out_fd, "\n"); diff --git a/src/shared/util.c b/src/shared/util.c index d6fdd31..2367524 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -224,7 +224,7 @@ int copy_bytes(int destfd, int srcfd, off_t *ncopied) return r == 0 ? r : copy_bytes_rw(destfd, srcfd, ncopied); } -int copy_file(char *src, char *dst) +int copy_file(char *dst, char *src) { int res; int sfd; @@ -253,16 +253,16 @@ int copy_file(char *src, char *dst) return res; } -int move_file(char *src, char *dst) +int move_file(char *dst, char *src) { - if (copy_file(src, dst) < 0) + if (copy_file(dst, src) < 0) return -1; if (unlink(src) < 0) return -1; return 1; } -int dump_file_write_fd(char *src, int dfd) +int dump_file_write_fd(int dfd, char *src) { int res; int sfd; diff --git a/src/shared/util.h b/src/shared/util.h index a010b7e..dfe40bf 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -41,11 +41,11 @@ int write_fd(int fd, const void *buf, int len); int copy_bytes(int destfd, int srcfd, off_t *ncopied); -int copy_file(char *src, char *dst); +int copy_file(char *dst, char *src); -int move_file(char *src, char *dst); +int move_file(char *dst, char *src); -int dump_file_write_fd(char *src, int dfd); +int dump_file_write_fd(int dfd, char *src); int run_command_write_fd_timeout(char *path, char *args[], char *env[], int dfd, char *buff, int size, int timeout); -- 2.7.4