[ltt-dev] [UST PATCH] Make libustctl list only online pids v2

Mathieu Desnoyers compudj at krystal.dyndns.org
Mon May 16 12:57:36 EDT 2011


* Nils Carlson (nils.carlson at ericsson.com) wrote:
> Changes since v1:
> Cosmetic surgery at a european cost
> 

:-)

[...]

> +static int ustcomm_get_sock_name(char *dir_name, pid_t pid, char *sock_name)
> +{
> +	struct dirent *dirent;
> +	char sock_path_base[101];
> +	int len;
> +	DIR *dir = opendir(dir_name);
> +
> +	snprintf(sock_path_base, 100, "%ld.", (long) pid);

May I suggest to add

#define MAX_SOCK_PATH_BASE_LEN	100

and use

char sock_path_base[MAX_SOCK_PATH_BASE_LEN];

snprintf(sock_path_base, MAX_SOCK_PATH_BASE_LEN - 1, "%ld.", (long) pid);

?

Hardcoding fixed array width, especially when they have a close
relationship one to another, is usually frowned upon.

The rest looks good. If you proceed to this change, please add my

Acked-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>

Thanks,

Mathieu

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




More information about the lttng-dev mailing list