diff options
author | Dan McGee <dan@archlinux.org> | 2011-10-21 22:24:04 +0200 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2011-10-24 17:57:51 +0200 |
commit | 156bfbddb98de91a3bf37740978e21baa3ecb9ba (patch) | |
tree | 7eaee7902078e8a4c650cf1958b5e3e8f0bdf8ca /scripts | |
parent | f5736ace651fd7c277a7729919b45504b830d728 (diff) | |
download | aur-156bfbddb98de91a3bf37740978e21baa3ecb9ba.tar.gz aur-156bfbddb98de91a3bf37740978e21baa3ecb9ba.tar.xz |
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 <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/aurblup/aurblup.c | 27 |
1 files 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); |