coccinelle: make use of the "type" FREE_AND_NULL() rule
[gitweb.git] / credential.c
index 7d6501d190a529933d501e7f7006a70c4897282b..0ab247ff40a03b6da6281814cc7b41edca934bb5 100644 (file)
@@ -63,9 +63,12 @@ static int credential_config_callback(const char *var, const char *value,
                key = dot + 1;
        }
 
-       if (!strcmp(key, "helper"))
-               string_list_append(&c->helpers, value);
-       else if (!strcmp(key, "username")) {
+       if (!strcmp(key, "helper")) {
+               if (*value)
+                       string_list_append(&c->helpers, value);
+               else
+                       string_list_clear(&c->helpers, 0);
+       } else if (!strcmp(key, "username")) {
                if (!c->username)
                        c->username = xstrdup(value);
        }
@@ -90,8 +93,7 @@ static void credential_apply_config(struct credential *c)
        c->configured = 1;
 
        if (!c->use_http_path && proto_is_http(c->protocol)) {
-               free(c->path);
-               c->path = NULL;
+               FREE_AND_NULL(c->path);
        }
 }