From 156bfbddb98de91a3bf37740978e21baa3ecb9ba Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 21 Oct 2011 15:24:04 -0500 Subject: aurblup: style cleanups Always use two lines for if statements, use a character constant rather than the 0 integer when NULL-terminating a string, and remove the unnecessary NULL check before free(value)- free(NULL) is a no-op and always safe. Signed-off-by: Dan McGee Signed-off-by: Lukas Fleischer --- scripts/aurblup/aurblup.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/aurblup/aurblup.c b/scripts/aurblup/aurblup.c index e01f0536..21808603 100644 --- a/scripts/aurblup/aurblup.c +++ b/scripts/aurblup/aurblup.c @@ -52,12 +52,13 @@ static alpm_list_t * pkglist_append(alpm_list_t *pkglist, const char *pkgname) { int len = strcspn(pkgname, "<=>"); - if (!len) len = strlen(pkgname); + if (!len) + len = strlen(pkgname); char *s = malloc(len + 1); strncpy(s, pkgname, len); - s[len] = 0; + s[len] = '\0'; if (alpm_list_find_str(pkglist, s)) free(s); @@ -217,10 +218,14 @@ read_config(const char *fn) t = &mysql_host; u = &mysql_socket; } - else if (strstr(line, CONFIG_KEY_USER)) t = &mysql_user; - else if (strstr(line, CONFIG_KEY_PASSWD)) t = &mysql_passwd; - else if (strstr(line, CONFIG_KEY_DB)) t = &mysql_db; - else t = NULL; + else if (strstr(line, CONFIG_KEY_USER)) + t = &mysql_user; + else if (strstr(line, CONFIG_KEY_PASSWD)) + t = &mysql_passwd; + else if (strstr(line, CONFIG_KEY_DB)) + t = &mysql_db; + else + t = NULL; if (t) { strtok(line, "\""); @@ -280,11 +285,11 @@ init(void) static void cleanup(void) { - if (mysql_host) free(mysql_host); - if (mysql_socket) free(mysql_socket); - if (mysql_user) free(mysql_user); - if (mysql_passwd) free(mysql_passwd); - if (mysql_db) free(mysql_db); + free(mysql_host); + free(mysql_socket); + free(mysql_user); + free(mysql_passwd); + free(mysql_db); alpm_release(); mysql_close(c); -- cgit v1.2.3-24-g4f1b