util: Unify function calling convention to specify destination first 67/192667/3
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 7 Nov 2018 11:00:18 +0000 (12:00 +0100)
committerKarol Lewandowski <lmctl@lmctl.net>
Wed, 7 Nov 2018 22:43:39 +0000 (23:43 +0100)
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 <k.lewandowsk@samsung.com>
src/crash-manager/crash-manager.c
src/dump_systemstate/dump_systemstate.c
src/shared/util.c
src/shared/util.h

index a02d59c..95cbf8b 100644 (file)
@@ -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;
index fb2ee75..d4c0e40 100644 (file)
@@ -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");
index d6fdd31..2367524 100644 (file)
@@ -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;
index a010b7e..dfe40bf 100644 (file)
@@ -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);