Commit 156bfbdd authored by Dan McGee's avatar Dan McGee Committed by Lukas Fleischer
Browse files

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: default avatarDan McGee <dan@archlinux.org>
Signed-off-by: default avatarLukas Fleischer <archlinux@cryptocrack.de>
parent f5736ace
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment