Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selinux: Unify for- and while-loop style

Replace "thing != NULL" comparisons with just "thing" to make
the code look more uniform (mixed styles were used even in the
same source file).

Signed-off-by: Vesa-Matti Kari <vmkari@cc.helsinki.fi>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: James Morris <jmorris@namei.org>

authored by

Vesa-Matti Kari and committed by
James Morris
dbc74c65 421fae06

+24 -24
+1 -1
security/selinux/ss/avtab.c
··· 229 229 230 230 for (i = 0; i < h->nslot; i++) { 231 231 cur = h->htable[i]; 232 - while (cur != NULL) { 232 + while (cur) { 233 233 temp = cur; 234 234 cur = cur->next; 235 235 kmem_cache_free(avtab_node_cachep, temp);
+8 -8
security/selinux/ss/conditional.c
··· 29 29 int s[COND_EXPR_MAXDEPTH]; 30 30 int sp = -1; 31 31 32 - for (cur = expr; cur != NULL; cur = cur->next) { 32 + for (cur = expr; cur; cur = cur->next) { 33 33 switch (cur->expr_type) { 34 34 case COND_BOOL: 35 35 if (sp == (COND_EXPR_MAXDEPTH - 1)) ··· 97 97 if (new_state == -1) 98 98 printk(KERN_ERR "SELinux: expression result was undefined - disabling all rules.\n"); 99 99 /* turn the rules on or off */ 100 - for (cur = node->true_list; cur != NULL; cur = cur->next) { 100 + for (cur = node->true_list; cur; cur = cur->next) { 101 101 if (new_state <= 0) 102 102 cur->node->key.specified &= ~AVTAB_ENABLED; 103 103 else 104 104 cur->node->key.specified |= AVTAB_ENABLED; 105 105 } 106 106 107 - for (cur = node->false_list; cur != NULL; cur = cur->next) { 107 + for (cur = node->false_list; cur; cur = cur->next) { 108 108 /* -1 or 1 */ 109 109 if (new_state) 110 110 cur->node->key.specified &= ~AVTAB_ENABLED; ··· 128 128 static void cond_av_list_destroy(struct cond_av_list *list) 129 129 { 130 130 struct cond_av_list *cur, *next; 131 - for (cur = list; cur != NULL; cur = next) { 131 + for (cur = list; cur; cur = next) { 132 132 next = cur->next; 133 133 /* the avtab_ptr_t node is destroy by the avtab */ 134 134 kfree(cur); ··· 139 139 { 140 140 struct cond_expr *cur_expr, *next_expr; 141 141 142 - for (cur_expr = node->expr; cur_expr != NULL; cur_expr = next_expr) { 142 + for (cur_expr = node->expr; cur_expr; cur_expr = next_expr) { 143 143 next_expr = cur_expr->next; 144 144 kfree(cur_expr); 145 145 } ··· 155 155 if (list == NULL) 156 156 return; 157 157 158 - for (cur = list; cur != NULL; cur = next) { 158 + for (cur = list; cur; cur = next) { 159 159 next = cur->next; 160 160 cond_node_destroy(cur); 161 161 } ··· 291 291 goto err; 292 292 } 293 293 found = 0; 294 - for (cur = other; cur != NULL; cur = cur->next) { 294 + for (cur = other; cur; cur = cur->next) { 295 295 if (cur->node == node_ptr) { 296 296 found = 1; 297 297 break; ··· 485 485 if (!ctab || !key || !avd) 486 486 return; 487 487 488 - for (node = avtab_search_node(ctab, key); node != NULL; 488 + for (node = avtab_search_node(ctab, key); node; 489 489 node = avtab_search_node_next(node, key->specified)) { 490 490 if ((u16)(AVTAB_ALLOWED|AVTAB_ENABLED) == 491 491 (node->key.specified & (AVTAB_ALLOWED|AVTAB_ENABLED)))
+2 -2
security/selinux/ss/ebitmap.c
··· 109 109 *catmap = c_iter; 110 110 c_iter->startbit = e_iter->startbit & ~(NETLBL_CATMAP_SIZE - 1); 111 111 112 - while (e_iter != NULL) { 112 + while (e_iter) { 113 113 for (i = 0; i < EBITMAP_UNIT_NUMS; i++) { 114 114 unsigned int delta, e_startbit, c_endbit; 115 115 ··· 197 197 } 198 198 } 199 199 c_iter = c_iter->next; 200 - } while (c_iter != NULL); 200 + } while (c_iter); 201 201 if (e_iter != NULL) 202 202 ebmap->highbit = e_iter->startbit + EBITMAP_SIZE; 203 203 else
+3 -3
security/selinux/ss/hashtab.c
··· 81 81 82 82 hvalue = h->hash_value(h, key); 83 83 cur = h->htable[hvalue]; 84 - while (cur != NULL && h->keycmp(h, key, cur->key) > 0) 84 + while (cur && h->keycmp(h, key, cur->key) > 0) 85 85 cur = cur->next; 86 86 87 87 if (cur == NULL || (h->keycmp(h, key, cur->key) != 0)) ··· 100 100 101 101 for (i = 0; i < h->size; i++) { 102 102 cur = h->htable[i]; 103 - while (cur != NULL) { 103 + while (cur) { 104 104 temp = cur; 105 105 cur = cur->next; 106 106 kfree(temp); ··· 127 127 128 128 for (i = 0; i < h->size; i++) { 129 129 cur = h->htable[i]; 130 - while (cur != NULL) { 130 + while (cur) { 131 131 ret = apply(cur->key, cur->datum, args); 132 132 if (ret) 133 133 return ret;
+4 -4
security/selinux/ss/services.c
··· 356 356 avkey.source_type = i + 1; 357 357 avkey.target_type = j + 1; 358 358 for (node = avtab_search_node(&policydb.te_avtab, &avkey); 359 - node != NULL; 359 + node; 360 360 node = avtab_search_node_next(node, avkey.specified)) { 361 361 if (node->key.specified == AVTAB_ALLOWED) 362 362 avd->allowed |= node->datum.data; ··· 1037 1037 /* If no permanent rule, also check for enabled conditional rules */ 1038 1038 if (!avdatum) { 1039 1039 node = avtab_search_node(&policydb.te_cond_avtab, &avkey); 1040 - for (; node != NULL; node = avtab_search_node_next(node, specified)) { 1040 + for (; node; node = avtab_search_node_next(node, specified)) { 1041 1041 if (node->key.specified & AVTAB_ENABLED) { 1042 1042 avdatum = &node->datum; 1043 1043 break; ··· 2050 2050 policydb.bool_val_to_struct[i]->state = 0; 2051 2051 } 2052 2052 2053 - for (cur = policydb.cond_list; cur != NULL; cur = cur->next) { 2053 + for (cur = policydb.cond_list; cur; cur = cur->next) { 2054 2054 rc = evaluate_cond_node(&policydb, cur); 2055 2055 if (rc) 2056 2056 goto out; ··· 2102 2102 if (booldatum) 2103 2103 booldatum->state = bvalues[i]; 2104 2104 } 2105 - for (cur = p->cond_list; cur != NULL; cur = cur->next) { 2105 + for (cur = p->cond_list; cur; cur = cur->next) { 2106 2106 rc = evaluate_cond_node(p, cur); 2107 2107 if (rc) 2108 2108 goto out;
+6 -6
security/selinux/ss/sidtab.c
··· 43 43 hvalue = SIDTAB_HASH(sid); 44 44 prev = NULL; 45 45 cur = s->htable[hvalue]; 46 - while (cur != NULL && sid > cur->sid) { 46 + while (cur && sid > cur->sid) { 47 47 prev = cur; 48 48 cur = cur->next; 49 49 } ··· 92 92 93 93 hvalue = SIDTAB_HASH(sid); 94 94 cur = s->htable[hvalue]; 95 - while (cur != NULL && sid > cur->sid) 95 + while (cur && sid > cur->sid) 96 96 cur = cur->next; 97 97 98 98 if (force && cur && sid == cur->sid && cur->context.len) ··· 103 103 sid = SECINITSID_UNLABELED; 104 104 hvalue = SIDTAB_HASH(sid); 105 105 cur = s->htable[hvalue]; 106 - while (cur != NULL && sid > cur->sid) 106 + while (cur && sid > cur->sid) 107 107 cur = cur->next; 108 108 if (!cur || sid != cur->sid) 109 109 return NULL; ··· 136 136 137 137 for (i = 0; i < SIDTAB_SIZE; i++) { 138 138 cur = s->htable[i]; 139 - while (cur != NULL) { 139 + while (cur) { 140 140 rc = apply(cur->sid, &cur->context, args); 141 141 if (rc) 142 142 goto out; ··· 155 155 156 156 for (i = 0; i < SIDTAB_SIZE; i++) { 157 157 cur = s->htable[i]; 158 - while (cur != NULL) { 158 + while (cur) { 159 159 if (context_cmp(&cur->context, context)) 160 160 return cur->sid; 161 161 cur = cur->next; ··· 242 242 243 243 for (i = 0; i < SIDTAB_SIZE; i++) { 244 244 cur = s->htable[i]; 245 - while (cur != NULL) { 245 + while (cur) { 246 246 temp = cur; 247 247 cur = cur->next; 248 248 context_destroy(&temp->context);