From: guenther Date: Fri, 11 Aug 2023 04:51:36 +0000 (+0000) Subject: msdosfs_times() doesn't need to copy timespecs onto the stack: just X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=502e0f15eadf9cbe35241a9373fce8ed25c95f51;p=openbsd msdosfs_times() doesn't need to copy timespecs onto the stack: just mark unix2dostime()'s first argument as a pointer to const and skip the copies. ok millert@ --- diff --git a/usr.sbin/makefs/msdos/direntry.h b/usr.sbin/makefs/msdos/direntry.h index 36e097f2ab1..77f8d7dd657 100644 --- a/usr.sbin/makefs/msdos/direntry.h +++ b/usr.sbin/makefs/msdos/direntry.h @@ -1,4 +1,4 @@ -/* $OpenBSD: direntry.h,v 1.2 2021/12/23 04:37:12 jsg Exp $ */ +/* $OpenBSD: direntry.h,v 1.3 2023/08/11 04:51:36 guenther Exp $ */ /* $NetBSD: direntry.h,v 1.13 1997/10/17 11:23:45 ws Exp $ */ /*- @@ -121,8 +121,8 @@ struct winentry { #define DD_YEAR_MASK 0xFE00 /* year - 1980 */ #define DD_YEAR_SHIFT 9 -void unix2dostime(struct timespec *tsp, int minuteswest, u_int16_t *ddp, - u_int16_t *dtp, u_int8_t *dhp); +void unix2dostime(const struct timespec *tsp, int minuteswest, + u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp); int unix2dosfn(u_char *un, u_char dn[11], int unlen, u_int gen); int unix2winfn(u_char *un, int unlen, struct winentry *wep, int cnt, int chksum); diff --git a/usr.sbin/makefs/msdos/msdosfs_conv.c b/usr.sbin/makefs/msdos/msdosfs_conv.c index a07f1486d6c..7b73c19bd6e 100644 --- a/usr.sbin/makefs/msdos/msdosfs_conv.c +++ b/usr.sbin/makefs/msdos/msdosfs_conv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_conv.c,v 1.2 2021/10/06 00:40:41 deraadt Exp $ */ +/* $OpenBSD: msdosfs_conv.c,v 1.3 2023/08/11 04:51:36 guenther Exp $ */ /* $NetBSD: msdosfs_conv.c,v 1.24 1997/10/17 11:23:54 ws Exp $ */ /*- @@ -91,7 +91,7 @@ u_short lastdtime; * file timestamps. The passed in unix time is assumed to be in GMT. */ void -unix2dostime(struct timespec *tsp, int minuteswest, u_int16_t *ddp, +unix2dostime(const struct timespec *tsp, int minuteswest, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp) { time_t t; diff --git a/usr.sbin/makefs/msdos/msdosfs_vnops.c b/usr.sbin/makefs/msdos/msdosfs_vnops.c index 901c9855e3b..51c00f6cf22 100644 --- a/usr.sbin/makefs/msdos/msdosfs_vnops.c +++ b/usr.sbin/makefs/msdos/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_vnops.c,v 1.9 2021/10/06 00:40:41 deraadt Exp $ */ +/* $OpenBSD: msdosfs_vnops.c,v 1.10 2023/08/11 04:51:36 guenther Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.17 2016/01/30 09:59:27 mlelstv Exp $ */ /*- @@ -93,10 +93,10 @@ static void msdosfs_times(struct msdosfsmount *pmp, struct denode *dep, const struct stat *st) { - struct timespec at = st->st_atimespec; - struct timespec mt = st->st_mtimespec; - unix2dostime(&at, pmp->pm_minuteswest, &dep->de_ADate, NULL, NULL); - unix2dostime(&mt, pmp->pm_minuteswest, &dep->de_MDate, &dep->de_MTime, NULL); + unix2dostime(&st->st_atim, pmp->pm_minuteswest, &dep->de_ADate, + NULL, NULL); + unix2dostime(&st->st_mtim, pmp->pm_minuteswest, &dep->de_MDate, + &dep->de_MTime, NULL); } /*