From d779eb53d506d40fbe7903da7b914a5bbd588954 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 23 Jul 2013 13:14:44 +0200 Subject: [PATCH] unix, windows: fix uv_fs_chown() function prototype Before this commit, uv_fs_chown() and uv_fs_fchown() took the uid and gid as signed integers which is wrong because uid_t and gid_t are unsigned on most all platforms and IDs that don't fit in a signed integer do exist. This is not an ABI change because the size of the uid and gid arguments do not change, only their sign. On Windows, uv_uid_t and uv_gid_t are typedef'd as unsigned char for reasons that are unclear. It doesn't matter: they get cast to ints when used as function arguments. The arguments themselves are unused. Partial fix for joyent/node#5890. --- include/uv-private/uv-unix.h | 4 ++-- include/uv.h | 4 ++-- src/unix/fs.c | 8 ++++---- src/win/fs.c | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/uv-private/uv-unix.h b/include/uv-private/uv-unix.h index 729082e0bc..9e83cd88f0 100644 --- a/include/uv-private/uv-unix.h +++ b/include/uv-private/uv-unix.h @@ -300,8 +300,8 @@ typedef struct { void* buf; \ size_t len; \ off_t off; \ - uid_t uid; \ - gid_t gid; \ + uv_uid_t uid; \ + uv_gid_t gid; \ double atime; \ double mtime; \ struct uv__work work_req; \ diff --git a/include/uv.h b/include/uv.h index c3c68cbb5f..3978def5c4 100644 --- a/include/uv.h +++ b/include/uv.h @@ -1642,10 +1642,10 @@ UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file, int mode, uv_fs_cb cb); UV_EXTERN int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, - int uid, int gid, uv_fs_cb cb); + uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb); UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, - int uid, int gid, uv_fs_cb cb); + uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb); enum uv_fs_event { diff --git a/src/unix/fs.c b/src/unix/fs.c index 2f58a563b3..dde1d3a85e 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -598,8 +598,8 @@ int uv_fs_chmod(uv_loop_t* loop, int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, - int uid, - int gid, + uv_uid_t uid, + uv_gid_t gid, uv_fs_cb cb) { INIT(CHOWN); PATH; @@ -631,8 +631,8 @@ int uv_fs_fchmod(uv_loop_t* loop, int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, - int uid, - int gid, + uv_uid_t uid, + uv_gid_t gid, uv_fs_cb cb) { INIT(FCHOWN); req->file = file; diff --git a/src/win/fs.c b/src/win/fs.c index 52290a9f56..e78bc1b80a 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -1672,8 +1672,8 @@ int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path, } -int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid, - int gid, uv_fs_cb cb) { +int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, + uv_gid_t gid, uv_fs_cb cb) { uv_fs_req_init(loop, req, UV_FS_CHOWN, cb); if (fs__capture_path(loop, req, path, NULL, cb != NULL) < 0) { @@ -1691,8 +1691,8 @@ int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid, } -int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, int uid, - int gid, uv_fs_cb cb) { +int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_uid_t uid, + uv_gid_t gid, uv_fs_cb cb) { uv_fs_req_init(loop, req, UV_FS_FCHOWN, cb); if (cb) {