Kamil Dudka 32fb61
From 51b9a8ba0974d262e0b0f81a2078b3c7907b25ed Mon Sep 17 00:00:00 2001
Kamil Dudka 32fb61
From: Paul Eggert <eggert@cs.ucla.edu>
Kamil Dudka 32fb61
Date: Wed, 7 Apr 2021 17:29:59 -0700
Kamil Dudka 32fb61
Subject: [PATCH] utimens: fix confusing arg type in internal func
Kamil Dudka 32fb61
MIME-Version: 1.0
Kamil Dudka 32fb61
Content-Type: text/plain; charset=UTF-8
Kamil Dudka 32fb61
Content-Transfer-Encoding: 8bit
Kamil Dudka 32fb61
Kamil Dudka 32fb61
Although the old code was technically correct, this was accidental
Kamil Dudka 32fb61
and it understandably confused Coverity.  Reported by Ondrej Dubaj in:
Kamil Dudka 32fb61
https://lists.gnu.org/r/bug-tar/2021-04/msg00000.html
Kamil Dudka 32fb61
* lib/utimens.c (update_timespec): Change arg type from ‘struct
Kamil Dudka 32fb61
timespec *[2]’ (pointer to array of 2 pointers to timespecs) to
Kamil Dudka 32fb61
‘struct timespec **’ (pointer to pointer to the first timespec in
Kamil Dudka 32fb61
an array of 2 timespecs).  Although the old code happened to be
Kamil Dudka 32fb61
technically correct, it was misleading and confused Coverity.
Kamil Dudka 32fb61
And though the type ‘struct timespec (**)[2]’ (pointer to pointer
Kamil Dudka 32fb61
to array of 2 timespecs) would perhaps be more technically
Kamil Dudka 32fb61
correct, it would be almost as confusing and would require changes
Kamil Dudka 32fb61
elsewhere in this file; let’s quit while we’re ahead.
Kamil Dudka 32fb61
Kamil Dudka 32fb61
Upstream-commit: a3a946f670718d0dee5a7425ad5ac0a29fb46ea1
Kamil Dudka 32fb61
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Kamil Dudka 32fb61
---
Kamil Dudka 32fb61
 lib/utimens.c | 6 +++---
Kamil Dudka 32fb61
 1 file changed, 3 insertions(+), 3 deletions(-)
Kamil Dudka 32fb61
Kamil Dudka 32fb61
diff --git a/lib/utimens.c b/lib/utimens.c
Kamil Dudka 32fb61
index 3f53942..ea8c672 100644
Kamil Dudka 32fb61
--- a/lib/utimens.c
Kamil Dudka 32fb61
+++ b/lib/utimens.c
Kamil Dudka 32fb61
@@ -123,14 +123,14 @@ validate_timespec (struct timespec timespec[2])
Kamil Dudka 32fb61
   return result + (utime_omit_count == 1);
Kamil Dudka 32fb61
 }
Kamil Dudka 32fb61
 
Kamil Dudka 32fb61
-/* Normalize any UTIME_NOW or UTIME_OMIT values in *TS, using stat
Kamil Dudka 32fb61
-   buffer STATBUF to obtain the current timestamps of the file.  If
Kamil Dudka 32fb61
+/* Normalize any UTIME_NOW or UTIME_OMIT values in (*TS)[0] and (*TS)[1],
Kamil Dudka 32fb61
+   using STATBUF to obtain the current timestamps of the file.  If
Kamil Dudka 32fb61
    both times are UTIME_NOW, set *TS to NULL (as this can avoid some
Kamil Dudka 32fb61
    permissions issues).  If both times are UTIME_OMIT, return true
Kamil Dudka 32fb61
    (nothing further beyond the prior collection of STATBUF is
Kamil Dudka 32fb61
    necessary); otherwise return false.  */
Kamil Dudka 32fb61
 static bool
Kamil Dudka 32fb61
-update_timespec (struct stat const *statbuf, struct timespec *ts[2])
Kamil Dudka 32fb61
+update_timespec (struct stat const *statbuf, struct timespec **ts)
Kamil Dudka 32fb61
 {
Kamil Dudka 32fb61
   struct timespec *timespec = *ts;
Kamil Dudka 32fb61
   if (timespec[0].tv_nsec == UTIME_OMIT
Kamil Dudka 32fb61
-- 
Kamil Dudka 32fb61
2.26.3
Kamil Dudka 32fb61