From 77845f7bd75cc1f1ac69bfae38a78aa81ae3fb60 Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Mon, 25 Jun 2018 14:01:21 +0200 Subject: [PATCH 1/3] ipcs,chmem: fix access() usage Some mistakes happened lately when switching from path_exist() to ul_path_access(). See f09a98de and 8ca31279. This caused ipcs test failures when running i386 binaries on x86_64 hosts, because the syscall fallback was always used. That's why I reviewed all similar changes and found another one in chmem. Signed-off-by: Ruediger Meier --- sys-utils/chmem.c | 2 +- sys-utils/ipcutils.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sys-utils/chmem.c b/sys-utils/chmem.c index e5eab096a..4a4439a22 100644 --- a/sys-utils/chmem.c +++ b/sys-utils/chmem.c @@ -428,7 +428,7 @@ int main(int argc, char **argv) /* The valid_zones sysfs attribute was introduced with kernel 3.18 */ - if (ul_path_access(desc->sysmem, F_OK, "memory0/valid_zones")) + if (ul_path_access(desc->sysmem, F_OK, "memory0/valid_zones") == 0) desc->have_zones = 1; else if (zone) warnx(_("zone ignored, no valid_zones sysfs attribute present")); diff --git a/sys-utils/ipcutils.c b/sys-utils/ipcutils.c index e6dd0c561..5fe297fd4 100644 --- a/sys-utils/ipcutils.c +++ b/sys-utils/ipcutils.c @@ -18,9 +18,9 @@ int ipc_msg_get_limits(struct ipc_limits *lim) { - if (access(_PATH_PROC_IPC_MSGMNI, F_OK) && - access(_PATH_PROC_IPC_MSGMNB, F_OK) && - access(_PATH_PROC_IPC_MSGMAX, F_OK)) { + if (access(_PATH_PROC_IPC_MSGMNI, F_OK) == 0 && + access(_PATH_PROC_IPC_MSGMNB, F_OK) == 0 && + access(_PATH_PROC_IPC_MSGMAX, F_OK) == 0) { ul_path_read_s32(NULL, &lim->msgmni, _PATH_PROC_IPC_MSGMNI); ul_path_read_s32(NULL, &lim->msgmnb, _PATH_PROC_IPC_MSGMNB); @@ -71,9 +71,9 @@ int ipc_shm_get_limits(struct ipc_limits *lim) { lim->shmmin = SHMMIN; - if (access(_PATH_PROC_IPC_SHMALL, F_OK) && - access(_PATH_PROC_IPC_SHMMAX, F_OK) && - access(_PATH_PROC_IPC_SHMMNI, F_OK)) { + if (access(_PATH_PROC_IPC_SHMALL, F_OK) == 0 && + access(_PATH_PROC_IPC_SHMMAX, F_OK) == 0 && + access(_PATH_PROC_IPC_SHMMNI, F_OK) == 0) { ul_path_read_u64(NULL, &lim->shmall, _PATH_PROC_IPC_SHMALL); ul_path_read_u64(NULL, &lim->shmmax, _PATH_PROC_IPC_SHMMAX); From 24c329bbb35d96ef261d21b77f559d8fca942bd4 Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Mon, 25 Jun 2018 14:23:42 +0200 Subject: [PATCH 2/3] lib/path: remove unused expression error: expression result unused [-Werror,-Wunused-value] prefix = optarg, "failed to parse range start"; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Ruediger Meier --- lib/path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/path.c b/lib/path.c index 34abb144a..9cc2e3e2e 100644 --- a/lib/path.c +++ b/lib/path.c @@ -1039,7 +1039,7 @@ int main(int argc, char *argv[]) while((c = getopt_long(argc, argv, "p:h", longopts, NULL)) != -1) { switch(c) { case 'p': - prefix = optarg, "failed to parse range start"; + prefix = optarg; break; case 'h': usage(); From 3097f788f99804957a8ffb3797ed49cb599daeb7 Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Mon, 25 Jun 2018 15:08:55 +0200 Subject: [PATCH 3/3] wipefs: add missing ifdef Seen on OSX: misc-utils/wipefs.c:822:5: warning: implicit declaration of function 'rereadpt' is invalid in C99 [-Wimplicit-function-declaration] rereadpt(fd, devname); Signed-off-by: Ruediger Meier --- misc-utils/wipefs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c index 49c5c8ca1..13a720e85 100644 --- a/misc-utils/wipefs.c +++ b/misc-utils/wipefs.c @@ -802,7 +802,6 @@ main(int argc, char **argv) /* * Erase */ - size_t i; ctl.ndevs = argc - optind; while (optind < argc) { @@ -811,10 +810,11 @@ main(int argc, char **argv) ctl.ndevs--; } +#ifdef BLKRRPART /* Re-read partition tables on whole-disk devices. This is * postponed until all is done to avoid conflicts. */ - for (i = 0; i < ctl.nrereads; i++) { + for (size_t i = 0; i < ctl.nrereads; i++) { char *devname = ctl.reread[i]; int fd = open(devname, O_RDONLY); @@ -824,6 +824,7 @@ main(int argc, char **argv) } } free(ctl.reread); +#endif } return EXIT_SUCCESS; }