Mailing List Archive

[PATCH] utimes: constify path
From: Mike Frysinger <vapier@chromium.org>

The standard C API uses a const string, and code in OpenSSH call this
with const strings, so fix the function definition to match. Otherwise:

sftp-client.c:1716:15: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
if (utimes(local_path, tv) == -1)
^~~~~~~~~~
./openbsd-compat/bsd-misc.h:65:18: note: passing argument to parameter here
int utimes(char *, struct timeval *);
^
sftp-client.c:1828:15: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
if (utimes(dst, tv) == -1)
^~~
./openbsd-compat/bsd-misc.h:65:18: note: passing argument to parameter here
int utimes(char *, struct timeval *);
^
2 warnings generated.
---
openbsd-compat/bsd-misc.c | 2 +-
openbsd-compat/bsd-misc.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 059b6d3b3ec7..d9c9b2671ef7 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -107,7 +107,7 @@ const char *strerror(int e)
#endif

#ifndef HAVE_UTIMES
-int utimes(char *filename, struct timeval *tvp)
+int utimes(const char *filename, struct timeval *tvp)
{
struct utimbuf ub;

diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index 2206e1a82140..61ead1b7fad0 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -62,7 +62,7 @@ struct timeval {
}
#endif /* HAVE_STRUCT_TIMEVAL */

-int utimes(char *, struct timeval *);
+int utimes(const char *, struct timeval *);
#endif /* HAVE_UTIMES */

#ifndef AT_FDCWD
--
2.34.1

_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev
Re: [PATCH] utimes: constify path [ In reply to ]
On Fri, 25 Feb 2022 at 05:02, Mike Frysinger <vapier@gentoo.org> wrote:
> The standard C API uses a const string, and code in OpenSSH call this
> with const strings, so fix the function definition to match.

Applied, thanks.

--
Darren Tucker (dtucker at dtucker.net)
GPG key 11EAA6FA / A86E 3E07 5B19 5880 E860 37F4 9357 ECEF 11EA A6FA (new)
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev