Re: [PATCH 01/11] last: include libgen.h for basename(3p)

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

 



On Thu, Dec 01, 2016 at 09:52:04AM +0100, Ruediger Meier wrote:
> From: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>
> 
> Signed-off-by: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>
> ---
>  login-utils/last.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/login-utils/last.c b/login-utils/last.c
> index 6d0e892..90eee68 100644
> --- a/login-utils/last.c
> +++ b/login-utils/last.c
> @@ -40,6 +40,7 @@
>  #include <netinet/in.h>
>  #include <netdb.h>
>  #include <arpa/inet.h>
> +#include <libgen.h>
>  
>  #include "c.h"
>  #include "nls.h"
> @@ -877,7 +878,11 @@ static void process_wtmp_file(const struct last_control *ctl,
>  		}
>  	}
>  
> -	printf(_("\n%s begins %s"), basename(filename), ctime(&begintime));
> +	{
> +		char* tmp = xstrdup(filename);
> +		printf(_("\n%s begins %s"), basename(tmp), ctime(&begintime));
> +		free(tmp);

 This seems like pretty common pattern, what about to introduce
 xbasename(filename, &tmp)?

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [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