memset (&fl, '\0', sizeof (struct flock)); \
fl.l_type = (type); \
fl.l_whence = SEEK_SET; \
- __fcntl ((fd), F_SETLKW, &fl)
+ if (__fcntl ((fd), F_SETLKW, &fl) < 0)
#define UNLOCK_FILE(fd) \
/* Unlock the file. */ \
return -1;
}
- LOCK_FILE (file_fd, F_RDLCK);
+ LOCK_FILE (file_fd, F_RDLCK)
+ {
+ *result = NULL;
+ return -1;
+ }
/* Read the next entry. */
nbytes = __read (file_fd, &last_entry, sizeof (struct utmp));
{
int result = -1;
- LOCK_FILE (file_fd, F_RDLCK);
+ LOCK_FILE (file_fd, F_RDLCK)
+ return result;
#if _HAVE_UT_TYPE - 0
if (id->ut_type == RUN_LVL || id->ut_type == BOOT_TIME
return -1;
}
- LOCK_FILE (file_fd, F_RDLCK);
+ LOCK_FILE (file_fd, F_RDLCK)
+ {
+ *result = NULL;
+ return -1;
+ }
while (1)
{
else
found = internal_getut_r (data, &buffer);
- LOCK_FILE (file_fd, F_WRLCK);
+ LOCK_FILE (file_fd, F_WRLCK)
+ return NULL;
if (found < 0)
{
if (fd < 0)
return -1;
- LOCK_FILE (fd, F_WRLCK);
+ LOCK_FILE (fd, F_WRLCK)
+ {
+ __close (fd);
+ return result;
+ }
/* Remember original size of log file. */
offset = __lseek64 (fd, 0, SEEK_END);