Re: [PATCH] basename.3: SYNOPSIS: Add missing 'const'

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

 



Hi Alex,

On 5/10/21 9:38 AM, Alejandro Colomar wrote:
> Glibc uses 'const' for the basename() parameter.
> Fix the prototype.

Yes, but see basename(3p):

    SYNOPSIS
       #include <libgen.h>

       char *basename(char *path);

       ...

       The basename() function may modify the string pointed to by  path,
       and may return a pointer to internal storage. The returned pointer
       might be invalidated or the storage might be overwritten by a sub‐
       sequent  call  to  basename().  The returned pointer might also be
       invalidated if the calling thread is terminated.

I'll skip this patch.

Thanks,

Michael

> ......
> 
> .../glibc$ grep_glibc_prototype basename
> string/string.h:511:
> extern char *basename (const char *__filename) __THROW __nonnull ((1));
> .../glibc$
> 
> Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx>
> ---
>  man3/basename.3 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/man3/basename.3 b/man3/basename.3
> index 65a14e8cb..51825eca4 100644
> --- a/man3/basename.3
> +++ b/man3/basename.3
> @@ -32,7 +32,7 @@ basename, dirname \- parse pathname components
>  .B #include <libgen.h>
>  .PP
>  .BI "char *dirname(char *" path );
> -.BI "char *basename(char *" path );
> +.BI "char *basename(const char *" path );
>  .fi
>  .SH DESCRIPTION
>  Warning: there are two different functions
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux