[PATCH] utimes: constify path

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

 



From: Mike Frysinger <vapier@xxxxxxxxxxxx>

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@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



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

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux