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