]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Move assignments out of conditions
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 25 May 2017 19:41:33 +0000 (15:41 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 25 May 2017 19:41:33 +0000 (15:41 -0400)
src/modules/rlm_passwd/rlm_passwd.c

index 12722dbb616d95e2da81d460bb1012c7b54f3323..cc0d5c1ef17443f3ae7c2ac1885ead0dbb2dc001 100644 (file)
@@ -189,12 +189,14 @@ static struct hashtable * build_hash_table (char const * file, int nfields,
        MEM(ht->table = talloc_zero_array(ht, struct mypasswd *, tablesize));
        while (fgets(buffer, 1024, ht->fp)) {
                if(*buffer && *buffer!='\n' && (!ignorenis || (*buffer != '+' && *buffer != '-')) ){
-                       if(!(hashentry = mypasswd_alloc(buffer, nfields, &len))){
+                       hashentry = mypasswd_alloc(buffer, nfields, &len);
+                       if (!hashentry){
                                release_hash_table(ht);
                                return ht;
                        }
+
                        len = string_to_entry(buffer, nfields, ht->delimiter, hashentry, len);
-                       if(!hashentry->field[keyfield] || *hashentry->field[keyfield] == '\0') {
+                       if (!hashentry->field[keyfield] || *hashentry->field[keyfield] == '\0') {
                                talloc_free(hashentry);
                                continue;
                        }
@@ -209,7 +211,7 @@ static struct hashtable * build_hash_table (char const * file, int nfields,
                        hashentry->next = ht->table[h];
                        ht->table[h] = hashentry;
                        if (islist) {
-                               for(list=nextlist; nextlist; list = nextlist){
+                               for (list=nextlist; nextlist; list = nextlist){
                                        for (nextlist = list; *nextlist && *nextlist!=','; nextlist++);
                                        if (*nextlist) *nextlist++ = 0;
                                        else nextlist = 0;
@@ -431,11 +433,16 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance)
                              inst->format);
                return -1;
        }
-       if (! (inst->ht = build_hash_table (inst->filename, nfields, keyfield, listable, inst->hash_size, inst->ignore_nislike, *inst->delimiter)) ){
+
+       inst->ht = build_hash_table(inst->filename, nfields, keyfield, listable,
+                                   inst->hash_size, inst->ignore_nislike, *inst->delimiter);
+       if (!inst->ht){
                ERROR("Can't build hashtable from passwd file");
                return -1;
        }
-       if (! (inst->pwdfmt = mypasswd_alloc(inst->format, nfields, &len)) ){
+
+       inst->pwdfmt = mypasswd_alloc(inst->format, nfields, &len);
+       if (!inst->pwdfmt){
                ERROR("Memory allocation failed");
                release_ht(inst->ht);
                inst->ht = NULL;