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