diff options
author | Egor Tensin <egor@tensin.name> | 2024-12-26 11:44:15 +0100 |
---|---|---|
committer | Egor Tensin <egor@tensin.name> | 2024-12-26 11:44:15 +0100 |
commit | b4df6f859a2c0804069a7c2fe26656d982828b1a (patch) | |
tree | d66be4321a52f609d04df1eb3ef27db541b172b3 | |
parent | Makefile: remove obsolete comment (diff) | |
download | cimple-b4df6f859a2c0804069a7c2fe26656d982828b1a.tar.gz cimple-b4df6f859a2c0804069a7c2fe26656d982828b1a.zip |
file: rename syscall wrappers
-rw-r--r-- | src/ci.c | 4 | ||||
-rw-r--r-- | src/cmd_line.c | 2 | ||||
-rw-r--r-- | src/file.c | 4 | ||||
-rw-r--r-- | src/file.h | 8 |
4 files changed, 11 insertions, 7 deletions
@@ -86,7 +86,7 @@ int ci_run_git_repo(const char *url, const char *rev, struct proc_output *output if (ret < 0) goto exit; - ret = my_chdir(git_repository_workdir(repo), &oldpwd); + ret = chdir_wrapper(git_repository_workdir(repo), &oldpwd); if (ret < 0) goto free_repo; @@ -95,7 +95,7 @@ int ci_run_git_repo(const char *url, const char *rev, struct proc_output *output goto oldpwd; oldpwd: - my_chdir(oldpwd, NULL); + chdir_wrapper(oldpwd, NULL); free(oldpwd); free_repo: diff --git a/src/cmd_line.c b/src/cmd_line.c index 35b27a7..bf3aa24 100644 --- a/src/cmd_line.c +++ b/src/cmd_line.c @@ -16,7 +16,7 @@ static char *get_current_binary_path(void) { - return my_readlink("/proc/self/exe"); + return readlink_wrapper("/proc/self/exe"); } static char *get_current_binary_name(void) @@ -36,7 +36,7 @@ int rm_rf(const char *dir) return nftw(dir, unlink_cb, 64, FTW_DEPTH | FTW_PHYS); } -int my_chdir(const char *dir, char **old) +int chdir_wrapper(const char *dir, char **old) { int ret = 0; @@ -63,7 +63,7 @@ free_old: return ret; } -char *my_readlink(const char *path) +char *readlink_wrapper(const char *path) { size_t current_size = 256; char *buf = NULL; @@ -12,8 +12,12 @@ int rm_rf(const char *dir); -int my_chdir(const char *dir, char **old); -char *my_readlink(const char *path); +/* This chdir(2) wrapper optionally saves the previous working directory in the + * `old` pointer, allowing the user to switch back to it if necessary. */ +int chdir_wrapper(const char *dir, char **old); + +/* This readlink(2) wrapper allocates enough memory dynamically. */ +char *readlink_wrapper(const char *path); int file_dup(int fd); void file_close(int fd); |