autofs-5.0.6 - update ->timeout() function to not return timeout From: Ian Kent The value returned by the ->timeout() autofs control interface function is not used so make that usage explict by not using a pass by address parameter. This saves having to take care to always use a temporary storage location when using the function. --- CHANGELOG | 1 + daemon/direct.c | 6 +++--- daemon/indirect.c | 2 +- include/dev-ioctl-lib.h | 2 +- lib/dev-ioctl-lib.c | 15 +++++++-------- lib/master_parse.y | 3 +-- lib/mounts.c | 4 ++-- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 12202cd..07199c4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -46,6 +46,7 @@ - fix configure string length tests for sss library. - report map not read when debug logging. - duplicate parent options for included maps. +- update ->timeout() function to not return timeout. 28/06/2011 autofs-5.0.6 ----------------------- diff --git a/daemon/direct.c b/daemon/direct.c index 4e8749b..aa8f8a0 100644 --- a/daemon/direct.c +++ b/daemon/direct.c @@ -302,7 +302,7 @@ static int unlink_active_mounts(struct autofs_point *ap, struct mnt_list *mnts, return 0; } - ops->timeout(ap->logopt, ioctlfd, &tout); + ops->timeout(ap->logopt, ioctlfd, tout); if (save_ioctlfd == -1) ops->close(ap->logopt, ioctlfd); @@ -424,7 +424,7 @@ int do_mount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struc goto out_umount; } - ops->timeout(ap->logopt, ioctlfd, &timeout); + ops->timeout(ap->logopt, ioctlfd, timeout); notify_mount_result(ap, me->key, str_direct); cache_set_ino_index(me->mc, me->key, st.st_dev, st.st_ino); ops->close(ap->logopt, ioctlfd); @@ -771,7 +771,7 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char * goto out_umount; } - ops->timeout(ap->logopt, ioctlfd, &timeout); + ops->timeout(ap->logopt, ioctlfd, timeout); cache_set_ino_index(me->mc, me->key, st.st_dev, st.st_ino); if (ap->logopt & LOGOPT_DEBUG) notify_mount_result(ap, mountpoint, str_offset); diff --git a/daemon/indirect.c b/daemon/indirect.c index f3651bd..a80f458 100644 --- a/daemon/indirect.c +++ b/daemon/indirect.c @@ -172,7 +172,7 @@ static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root) ap->dev = st.st_dev; /* Device number for mount point checks */ ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO; - ops->timeout(ap->logopt, ap->ioctlfd, &timeout); + ops->timeout(ap->logopt, ap->ioctlfd, timeout); if (ap->logopt & LOGOPT_DEBUG) notify_mount_result(ap, root, str_indirect); else diff --git a/include/dev-ioctl-lib.h b/include/dev-ioctl-lib.h index 6d35da2..b96e0dd 100644 --- a/include/dev-ioctl-lib.h +++ b/include/dev-ioctl-lib.h @@ -45,7 +45,7 @@ struct ioctl_ops { int (*send_fail)(unsigned int, int, unsigned int, int); int (*setpipefd)(unsigned int, int, int); int (*catatonic)(unsigned int, int); - int (*timeout)(unsigned int, int, time_t *); + int (*timeout)(unsigned int, int, time_t); int (*requestor)(unsigned int, int, const char *, uid_t *, gid_t *); int (*expire)(unsigned int, int, const char *, unsigned int); int (*askumount)(unsigned int, int, unsigned int *); diff --git a/lib/dev-ioctl-lib.c b/lib/dev-ioctl-lib.c index a034a3d..36d4df4 100644 --- a/lib/dev-ioctl-lib.c +++ b/lib/dev-ioctl-lib.c @@ -55,7 +55,7 @@ static int dev_ioctl_send_ready(unsigned int, int, unsigned int); static int dev_ioctl_send_fail(unsigned int, int, unsigned int, int); static int dev_ioctl_setpipefd(unsigned int, int, int); static int dev_ioctl_catatonic(unsigned int, int); -static int dev_ioctl_timeout(unsigned int, int, time_t *); +static int dev_ioctl_timeout(unsigned int, int, time_t); static int dev_ioctl_requestor(unsigned int, int, const char *, uid_t *, gid_t *); static int dev_ioctl_expire(unsigned int, int, const char *, unsigned int); static int dev_ioctl_askumount(unsigned int, int, unsigned int *); @@ -69,7 +69,7 @@ static int ioctl_close(unsigned int, int); static int ioctl_send_ready(unsigned int, int, unsigned int); static int ioctl_send_fail(unsigned int, int, unsigned int, int); static int ioctl_catatonic(unsigned int, int); -static int ioctl_timeout(unsigned int, int, time_t *); +static int ioctl_timeout(unsigned int, int, time_t); static int ioctl_expire(unsigned int, int, const char *, unsigned int); static int ioctl_askumount(unsigned int, int, unsigned int *); @@ -577,25 +577,24 @@ static int ioctl_catatonic(unsigned int logopt, int ioctlfd) } /* Set the autofs mount timeout */ -static int dev_ioctl_timeout(unsigned int logopt, int ioctlfd, time_t *timeout) +static int dev_ioctl_timeout(unsigned int logopt, int ioctlfd, time_t timeout) { struct autofs_dev_ioctl param; init_autofs_dev_ioctl(¶m); param.ioctlfd = ioctlfd; - param.timeout.timeout = *timeout; + param.timeout.timeout = timeout; if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_TIMEOUT, ¶m) == -1) return -1; - *timeout = param.timeout.timeout; - return 0; } -static int ioctl_timeout(unsigned int logopt, int ioctlfd, time_t *timeout) +static int ioctl_timeout(unsigned int logopt, int ioctlfd, time_t timeout) { - return ioctl(ioctlfd, AUTOFS_IOC_SETTIMEOUT, timeout); + time_t tout = timeout; + return ioctl(ioctlfd, AUTOFS_IOC_SETTIMEOUT, &tout); } /* diff --git a/lib/master_parse.y b/lib/master_parse.y index d56d044..0f6d41b 100644 --- a/lib/master_parse.y +++ b/lib/master_parse.y @@ -801,7 +801,6 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne } else { struct ioctl_ops *ops = get_ioctl_ops(); struct autofs_point *ap = entry->ap; - time_t tout = timeout; /* * Second and subsequent instances of a mount point @@ -811,7 +810,7 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne ap->exp_timeout = timeout; ap->exp_runfreq = (ap->exp_timeout + CHECK_RATIO - 1) / CHECK_RATIO; if (ap->ioctlfd != -1 && ap->type == LKP_INDIRECT) - ops->timeout(ap->logopt, ap->ioctlfd, &tout); + ops->timeout(ap->logopt, ap->ioctlfd, timeout); } } if (random_selection) diff --git a/lib/mounts.c b/lib/mounts.c index e0c2326..8be5ec7 100644 --- a/lib/mounts.c +++ b/lib/mounts.c @@ -1404,7 +1404,7 @@ static int remount_active_mount(struct autofs_point *ap, /* Re-reading the map, set timeout and return */ if (ap->state == ST_READMAP) { - ops->timeout(ap->logopt, fd, &timeout); + ops->timeout(ap->logopt, fd, timeout); ops->close(ap->logopt, fd); return REMOUNT_READ_MAP; } @@ -1426,7 +1426,7 @@ static int remount_active_mount(struct autofs_point *ap, ops->close(ap->logopt, fd); return REMOUNT_OPEN_FAIL; } - ops->timeout(ap->logopt, fd, &timeout); + ops->timeout(ap->logopt, fd, timeout); if (fstat(fd, &st) == -1) { error(ap->logopt, "failed to stat %s mount %s", str_type, path);