summaryrefslogtreecommitdiff
path: root/libc/pwd_grp
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-12-01 21:16:46 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-12-01 21:16:46 +0000
commitb0a365f74a0ac43fcbd53738844e577b2d9ec391 (patch)
tree262cc91ab047162f77df33a48891499434b56ca0 /libc/pwd_grp
parentfbb32ad9b6a4b6cffea1c5b4292b18c72cdadaf6 (diff)
hostid: improve extremely unreadable parts
*: remove checks of sigaction and sigprocmask results in cases where they clearly can't fail: sigaction(known_good_sig) sigprocmask(known_good_how) text data bss dec hex filename - 393 4 0 397 18d libc/pwd_grp/lckpwdf.o + 382 4 0 386 182 libc/pwd_grp/lckpwdf.o - 56 0 0 56 38 libc/signal/sigblock.o + 44 0 0 44 2c libc/signal/sigblock.o - 211 0 0 211 d3 libc/signal/sigset.o + 202 0 0 202 ca libc/signal/sigset.o - 56 0 0 56 38 libc/signal/sigsetmask.o + 44 0 0 44 2c libc/signal/sigsetmask.o - 309 0 0 309 135 libc/unistd/sleep.o + 256 0 0 256 100 libc/unistd/sleep.o
Diffstat (limited to 'libc/pwd_grp')
-rw-r--r--libc/pwd_grp/lckpwdf.c36
1 files changed, 3 insertions, 33 deletions
diff --git a/libc/pwd_grp/lckpwdf.c b/libc/pwd_grp/lckpwdf.c
index 9b0b604e0..c0c8f0d90 100644
--- a/libc/pwd_grp/lckpwdf.c
+++ b/libc/pwd_grp/lckpwdf.c
@@ -80,25 +80,8 @@ lckpwdf (void)
/* Make sure file gets correctly closed when process finished. */
flags = fcntl (lock_fd, F_GETFD);
-#if 0 /* never fails */
- if (flags == -1) {
- /* Cannot get file flags. */
- close(lock_fd);
- lock_fd = -1;
- goto DONE;
- }
-#endif
flags |= FD_CLOEXEC;
-#if 1
fcntl (lock_fd, F_SETFD, flags);
-#else /* never fails */
- if (fcntl (lock_fd, F_SETFD, flags) < 0) {
- /* Cannot set new flags. */
- close(lock_fd);
- lock_fd = -1;
- goto DONE;
- }
-#endif
/* Now we have to get exclusive write access. Since multiple
process could try this we won't stop when it first fails.
Instead we set a timeout for the system call. Once the timer
@@ -112,27 +95,14 @@ lckpwdf (void)
new_act.sa_handler = noop_handler;
__sigfillset (&new_act.sa_mask);
- /* Install new action handler for alarm and save old. */
- if (sigaction (SIGALRM, &new_act, &saved_act) < 0) {
- /* Cannot install signal handler. */
- close(lock_fd);
- lock_fd = -1;
- goto DONE;
- }
+ /* Install new action handler for alarm and save old.
+ * This never fails in Linux. */
+ sigaction (SIGALRM, &new_act, &saved_act);
/* Now make sure the alarm signal is not blocked. */
__sigemptyset (&new_set);
__sigaddset (&new_set, SIGALRM);
-#if 1
sigprocmask (SIG_UNBLOCK, &new_set, &saved_set);
-#else /* never fails */
- if (sigprocmask (SIG_UNBLOCK, &new_set, &saved_set) < 0) {
- sigaction (SIGALRM, &saved_act, NULL);
- close(lock_fd);
- lock_fd = -1;
- goto DONE;
- }
-#endif
/* Start timer. If we cannot get the lock in the specified time we
get a signal. */