diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-06-07 08:38:44 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-06-07 10:30:52 -0700 |
| commit | e7b40195ae0082d04ea8c0d1769d90ea700b76f2 (patch) | |
| tree | 9fe5edac29224af937c16aed1c477a313e4f4714 /compat/basename.c | |
| parent | 9c076c32fbb15a0887a1ed4d2afa7e5a3fd74727 (diff) | |
| download | git-e7b40195ae0082d04ea8c0d1769d90ea700b76f2.tar.gz | |
compat/win32: fix const-correctness with string constants
Adjust various places in our Win32 compatibility layer where we are not
assigning string constants to `const char *` variables.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/basename.c')
| -rw-r--r-- | compat/basename.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/compat/basename.c b/compat/basename.c index 96bd9533b4..c33579ef61 100644 --- a/compat/basename.c +++ b/compat/basename.c @@ -10,7 +10,13 @@ char *gitbasename (char *path) skip_dos_drive_prefix(&path); if (!path || !*path) - return "."; + /* + * basename(3P) is mis-specified because it returns a + * non-constant pointer even though it is specified to return a + * pointer to internal memory at times. The cast is a result of + * that. + */ + return (char *) "."; for (base = path; *path; path++) { if (!is_dir_sep(*path)) @@ -34,7 +40,13 @@ char *gitdirname(char *path) int dos_drive_prefix; if (!p) - return "."; + /* + * dirname(3P) is mis-specified because it returns a + * non-constant pointer even though it is specified to return a + * pointer to internal memory at times. The cast is a result of + * that. + */ + return (char *) "."; if ((dos_drive_prefix = skip_dos_drive_prefix(&p)) && !*p) goto dot; |
