Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/fs/vfs Initialise the sometvs array of struct timeval ...



details:   https://anonhg.NetBSD.org/src/rev/2fba5f91b957
branches:  trunk
changeset: 454559:2fba5f91b957
user:      kre <kre%NetBSD.org@localhost>
date:      Sat Sep 21 14:25:42 2019 +0000

description:
Initialise the sometvs array of struct timeval that is to be used to
validate that utimes() cannot update the times of a file on a read only
filesystem.   The values are never actually used, but since
        src/sys/kern/vfs_syscalls.c 1.535
they are validated for sanity, and the syscall returns EINVAL if the
values passed are invalid (tv_usec <0 or >= 1000000).  If that happens
we don't get as far as the test which produces the EROFS that is expected
from this test (these tests - one for each filesystem type).

So, init the timeval structs (just to 0, the values will still not be
used) so that the EINVAL doesn't bite us before we're eaten by the EROFS
which is the way we're supposed to die.

If the syscall API args were labelled as "const" the compiler probably
would have caught the use of uninit'd vars and complained much sooner.

diffstat:

 tests/fs/vfs/t_ro.c |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (18 lines):

diff -r 3b3c07bd5510 -r 2fba5f91b957 tests/fs/vfs/t_ro.c
--- a/tests/fs/vfs/t_ro.c       Sat Sep 21 14:25:33 2019 +0000
+++ b/tests/fs/vfs/t_ro.c       Sat Sep 21 14:25:42 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ro.c,v 1.7 2019/07/16 17:29:17 martin Exp $  */
+/*     $NetBSD: t_ro.c,v 1.8 2019/09/21 14:25:42 kre Exp $     */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -120,7 +120,7 @@
 static void
 attrs(const atf_tc_t *tc, const char *mp)
 {
-       struct timeval sometvs[2];
+       struct timeval sometvs[2] = { {0,0}, {0,0} };
        struct stat sb;
        int fd;
 



Home | Main Index | Thread Index | Old Index