Use null check convention in account.c

This commit is contained in:
James Booth
2015-05-04 22:29:51 +01:00
parent 4acf853b1c
commit 47549452f1

View File

@@ -57,19 +57,19 @@ account_new(const gchar * const name, const gchar * const jid,
new_account->name = strdup(name); new_account->name = strdup(name);
if (jid != NULL) { if (jid) {
new_account->jid = strdup(jid); new_account->jid = strdup(jid);
} else { } else {
new_account->jid = strdup(name); new_account->jid = strdup(name);
} }
if (password != NULL) { if (password) {
new_account->password = strdup(password); new_account->password = strdup(password);
} else { } else {
new_account->password = NULL; new_account->password = NULL;
} }
if (eval_password != NULL) { if (eval_password) {
new_account->eval_password = strdup(eval_password); new_account->eval_password = strdup(eval_password);
} else { } else {
new_account->eval_password = NULL; new_account->eval_password = NULL;
@@ -77,13 +77,13 @@ account_new(const gchar * const name, const gchar * const jid,
new_account->enabled = enabled; new_account->enabled = enabled;
if (server != NULL) { if (server) {
new_account->server = strdup(server); new_account->server = strdup(server);
} else { } else {
new_account->server = NULL; new_account->server = NULL;
} }
if (resource != NULL) { if (resource) {
new_account->resource = strdup(resource); new_account->resource = strdup(resource);
} else { } else {
new_account->resource = NULL; new_account->resource = NULL;
@@ -134,7 +134,7 @@ account_new(const gchar * const name, const gchar * const jid,
new_account->muc_nick = strdup(muc_nick); new_account->muc_nick = strdup(muc_nick);
} }
if (otr_policy != NULL) { if (otr_policy) {
new_account->otr_policy = strdup(otr_policy); new_account->otr_policy = strdup(otr_policy);
} else { } else {
new_account->otr_policy = NULL; new_account->otr_policy = NULL;
@@ -150,7 +150,7 @@ account_new(const gchar * const name, const gchar * const jid,
char * char *
account_create_full_jid(ProfAccount *account) account_create_full_jid(ProfAccount *account)
{ {
if (account->resource != NULL) { if (account->resource) {
return create_fulljid(account->jid, account->resource); return create_fulljid(account->jid, account->resource);
} else { } else {
return strdup(account->jid); return strdup(account->jid);
@@ -198,7 +198,7 @@ account_eval_password(ProfAccount *account)
void void
account_free(ProfAccount *account) account_free(ProfAccount *account)
{ {
if (account != NULL) { if (account) {
free(account->name); free(account->name);
free(account->jid); free(account->jid);
free(account->password); free(account->password);