[lttng-dev] [PATCH 1/3] Improve delete of configuration

David Goulet david.goulet at polymtl.ca
Tue May 29 14:43:08 EDT 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Francis,

Thanks for the patch. I'll just ask you small adjustments that follow code
"standard" and call convention. I know this is not that fun to fix but it
makes thing easier after all :).

On 28/05/12 01:00 PM, Francis Giraldeau wrote:
> Adding functions to encapsulate the configuration delete. Test if path to 
> configuration exists before attempting to remove it.
> 
> Signed-off-by: Francis Giraldeau <francis.giraldeau at gmail.com> --- 
> src/bin/lttng/conf.c |   36 +++++++++++++++++++++++++++++++++++- 
> src/bin/lttng/conf.h |    2 ++ 2 files changed, 37 insertions(+), 1
> deletion(-)
> 
> diff --git a/src/bin/lttng/conf.c b/src/bin/lttng/conf.c index
> 6f290b7..fe6898e 100644 --- a/src/bin/lttng/conf.c +++
> b/src/bin/lttng/conf.c @@ -154,15 +154,49 @@ void config_destroy(char
> *path) return; }
> 
> +	if (!config_exists(config_path)) +		goto done;

Please add {} even for a one liner if().

> + +	DBG("Removing %s\n", config_path); ret = remove(config_path); if (ret <
> 0) { perror("remove config file"); } - +done:

Accross the code, we uses "end:" instead of "done:".

> free(config_path); }
> 
> /* + *  config_destroy_default + * + *  Destroys the default config + */ +

No space here and no double space before "*__Destr..." . Most of the comments
are still like that in that file but we are trying to move away from that
comments format.

> +void config_destroy_default(void) +{ +	char *path =
> config_get_default_path(); +	if (path == NULL) +		return;

Add {}

> +	config_destroy(path); +} + +/* + *  config_exists + * + *  Returns 1 if
> config exists, 0 otherwise + */ +int config_exists(const char *path) +{ +
> int ret; +	struct stat info; + +	ret = stat(path, &info); +	if (ret < 0) +
> return 0;

Add {}

Thanks a lot!
David

> +	return S_ISREG(info.st_mode) || S_ISDIR(info.st_mode); +} + +/* *
> config_read_session_name * *  Returns the session name from the config
> file. diff --git a/src/bin/lttng/conf.h b/src/bin/lttng/conf.h index
> 1c471da..2cb04b0 100644 --- a/src/bin/lttng/conf.h +++
> b/src/bin/lttng/conf.h @@ -21,6 +21,8 @@ #define CONFIG_FILENAME
> ".lttngrc"
> 
> void config_destroy(char *path); +void config_destroy_default(void); +int
> config_exists(const char *path); int config_init(char *path); int
> config_add_session_name(char *path, char *name); char
> *config_get_default_path(void);
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBAgAGBQJPxRi5AAoJEELoaioR9I02NZgH/3yQH/B+XTHTv6DR+VS4KYcU
FO+NQIHK+jP4z3C7/FA/blfkFiJxjsv3SjSg8+6wVC+6deAflQ8avtT8FIIXMeRi
WTbnYBC6xm1QTVP/UQFOadpf3r36P6je0AX7YxqZqyjn0nDkyN/BU/TPnaeTz2zg
XzbSMItmzaeoGzMJnRL/7CpR6SAh+RpVmnwogNF85Y3yhAdSnrND08A33DDu5kU1
/FS2MpcwEQTXjld6PEVplKwDcQGCYmOtTiJWHdRFyZCTDVPJGFYz+0RTyx85EhCt
0SfGm6TdhpMFM3uybL8hbZsF1ndyk0ZcEgXmUchIpJA/ZYhN304erF0xLB65K4I=
=kd2K
-----END PGP SIGNATURE-----



More information about the lttng-dev mailing list