foo == NULL to !foo
authorAlan T. DeKok <aland@freeradius.org>
Fri, 29 Mar 2013 20:29:10 +0000 (16:29 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 29 Mar 2013 20:29:10 +0000 (16:29 -0400)
perl -p -i -e 's/([^ ()|=]+) == NULL/!$1/g' $(find src/modules/ -name "*.c" -print)

49 files changed:
src/modules/rlm_attr_filter/rlm_attr_filter.c
src/modules/rlm_attr_rewrite/rlm_attr_rewrite.c
src/modules/rlm_counter/rlm_counter.c
src/modules/rlm_detail/rlm_detail.c
src/modules/rlm_dhcp/rlm_dhcp.c
src/modules/rlm_digest/rlm_digest.c
src/modules/rlm_eap/eap.c
src/modules/rlm_eap/libeap/eap_tls.c
src/modules/rlm_eap/libeap/eapcommon.c
src/modules/rlm_eap/libeap/eapsimlib.c
src/modules/rlm_eap/radeapclient.c
src/modules/rlm_eap/rlm_eap.c
src/modules/rlm_eap/types/rlm_eap_gtc/rlm_eap_gtc.c
src/modules/rlm_eap/types/rlm_eap_ikev2/rlm_eap_ikev2.c
src/modules/rlm_eap/types/rlm_eap_leap/eap_leap.c
src/modules/rlm_eap/types/rlm_eap_leap/rlm_eap_leap.c
src/modules/rlm_eap/types/rlm_eap_md5/eap_md5.c
src/modules/rlm_eap/types/rlm_eap_md5/rlm_eap_md5.c
src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c
src/modules/rlm_eap/types/rlm_eap_peap/peap.c
src/modules/rlm_eap/types/rlm_eap_pwd/rlm_eap_pwd.c
src/modules/rlm_eap/types/rlm_eap_sim/rlm_eap_sim.c
src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.c
src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c
src/modules/rlm_eap2/rlm_eap2.c
src/modules/rlm_ippool/rlm_ippool.c
src/modules/rlm_ippool/rlm_ippool_tool.c
src/modules/rlm_linelog/rlm_linelog.c
src/modules/rlm_mschap/opendir.c
src/modules/rlm_opendirectory/rlm_opendirectory.c
src/modules/rlm_pap/rlm_pap.c
src/modules/rlm_passwd/rlm_passwd.c
src/modules/rlm_perl/rlm_perl.c
src/modules/rlm_preprocess/rlm_preprocess.c
src/modules/rlm_python/rlm_python.c
src/modules/rlm_realm/rlm_realm.c
src/modules/rlm_redis/rlm_redis.c
src/modules/rlm_rest/rest.c
src/modules/rlm_rest/rlm_rest.c
src/modules/rlm_ruby/rlm_ruby.c
src/modules/rlm_securid/rlm_securid.c
src/modules/rlm_sql/drivers/rlm_sql_freetds/rlm_sql_freetds.c
src/modules/rlm_sql/drivers/rlm_sql_iodbc/rlm_sql_iodbc.c
src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c
src/modules/rlm_sql/drivers/rlm_sql_postgresql/rlm_sql_postgresql.c
src/modules/rlm_sql/drivers/rlm_sql_sybase/rlm_sql_sybase.c
src/modules/rlm_sql/rlm_sql.c
src/modules/rlm_sql/sql.c
src/modules/rlm_unix/rlm_unix.c

index fada64d..1304813 100644 (file)
@@ -321,7 +321,7 @@ static rlm_rcode_t attr_filter_common(void *instance, REQUEST *request,
         *      No entry matched.  We didn't do anything.
         */
        if (!found) {
-               rad_assert(output == NULL);
+               rad_assert(!output);
                return RLM_MODULE_NOOP;
        }
 
index aca30ed..9547dfb 100644 (file)
@@ -102,11 +102,11 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        /*
         *      Discover the attribute number of the key.
         */
-       if (inst->attribute == NULL) {
+       if (!inst->attribute) {
                radlog(L_ERR, "rlm_attr_rewrite: 'attribute' must be set.");
                return -1;
        }
-       if (inst->search == NULL || inst->replace == NULL) {
+       if (!inst->search || !inst->replace) {
                radlog(L_ERR, "rlm_attr_rewrite: search/replace strings must be set.");
                return -1;
        }
@@ -122,7 +122,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
                radlog(L_ERR, "rlm_attr_rewrite: Illegal range for match number.");
                return -1;
        }
-       if (inst->searchin_str == NULL) {
+       if (!inst->searchin_str) {
                radlog(L_ERR, "rlm_attr_rewrite: Illegal searchin directive given. Assuming packet.");
                inst->searchin = RLM_REGEX_INPACKET;
        }
@@ -147,7 +147,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
                }
        }
        dattr = dict_attrbyname(inst->attribute);
-       if (dattr == NULL) {
+       if (!dattr) {
                radlog(L_ERR, "rlm_attr_rewrite: No such attribute %s",
                                inst->attribute);
                return -1;
@@ -181,7 +181,7 @@ static rlm_rcode_t do_attr_rewrite(void *instance, REQUEST *request)
        char replace_STR[MAX_STRING_LEN];
 
        if ((attr_vp = pairfind(request->config_items, PW_REWRITE_RULE, 0, TAG_ANY)) != NULL){
-               if (inst->name == NULL || strcmp(inst->name,attr_vp->vp_strvalue))
+               if (!inst->name || strcmp(inst->name,attr_vp->vp_strvalue))
                        return RLM_MODULE_NOOP;
        }
 
@@ -196,7 +196,7 @@ static rlm_rcode_t do_attr_rewrite(void *instance, REQUEST *request)
                 *      @todo: this shouldn't really be the request.
                 */
                attr_vp = pairmake(request, NULL, inst->attribute,replace_STR,0);
-               if (attr_vp == NULL){
+               if (!attr_vp){
                        DEBUG2("%s: Could not add new attribute %s with value '%s'", inst->name,
                                inst->attribute,replace_STR);
                        return rcode;
@@ -275,7 +275,7 @@ static rlm_rcode_t do_attr_rewrite(void *instance, REQUEST *request)
 do_again:
                if (tmp != NULL)
                        attr_vp = pairfind(tmp, inst->da->attr, inst->da->vendor, TAG_ANY);
-               if (attr_vp == NULL) {
+               if (!attr_vp) {
                        DEBUG2("%s: Could not find value pair for attribute %s", inst->name,inst->attribute);
                        return rcode;
                }
index dc58c5b..808d400 100644 (file)
@@ -150,7 +150,7 @@ static int counter_cmp(void *instance,
         *      Find the key attribute.
         */
        key_vp = pairfind(request, inst->key_attr, 0, TAG_ANY);
-       if (key_vp == NULL) {
+       if (!key_vp) {
                return RLM_MODULE_NOOP;
        }
 
@@ -159,7 +159,7 @@ static int counter_cmp(void *instance,
 
        count_datum = gdbm_fetch(inst->gdbm, key_datum);
 
-       if (count_datum.dptr == NULL) {
+       if (!count_datum.dptr) {
                return -1;
        }
        memcpy(&counter, count_datum.dptr, sizeof(rad_counter));
@@ -220,7 +220,7 @@ static rlm_rcode_t reset_db(rlm_counter_t *inst)
         */
        inst->gdbm = gdbm_open(inst->filename, sizeof(int),
                        GDBM_NEWDB | GDBM_COUNTER_OPTS, 0600, NULL);
-       if (inst->gdbm == NULL) {
+       if (!inst->gdbm) {
                radlog(L_ERR, "rlm_counter: Failed to open file %s: %s",
                                inst->filename, strerror(errno));
                return RLM_MODULE_FAIL;
@@ -258,7 +258,7 @@ static int find_next_reset(rlm_counter_t *inst, time_t timeval)
        if (len == 0) *sCurrentTime = '\0';
        tm->tm_sec = tm->tm_min = 0;
 
-       if (inst->reset == NULL)
+       if (!inst->reset)
                return -1;
        if (isdigit((int) inst->reset[0])){
                len = strlen(inst->reset);
@@ -353,13 +353,13 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        /*
         *      Discover the attribute number of the key.
         */
-       if (inst->key_name == NULL) {
+       if (!inst->key_name) {
                radlog(L_ERR, "rlm_counter: 'key' must be set.");
                mod_detach(inst);
                return -1;
        }
        dattr = dict_attrbyname(inst->key_name);
-       if (dattr == NULL) {
+       if (!dattr) {
                radlog(L_ERR, "rlm_counter: No such attribute %s",
                                inst->key_name);
                mod_detach(inst);
@@ -370,13 +370,13 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        /*
         *      Discover the attribute number of the counter.
         */
-       if (inst->count_attribute == NULL) {
+       if (!inst->count_attribute) {
                radlog(L_ERR, "rlm_counter: 'count-attribute' must be set.");
                mod_detach(inst);
                return -1;
        }
        dattr = dict_attrbyname(inst->count_attribute);
-       if (dattr == NULL) {
+       if (!dattr) {
                radlog(L_ERR, "rlm_counter: No such attribute %s",
                                inst->count_attribute);
                mod_detach(inst);
@@ -389,7 +389,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
         */
        if (inst->reply_name != NULL) {
                dattr = dict_attrbyname(inst->reply_name);
-               if (dattr == NULL) {
+               if (!dattr) {
                        radlog(L_ERR, "rlm_counter: No such attribute %s",
                                        inst->reply_name);
                        mod_detach(inst);
@@ -408,7 +408,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        /*
         *  Create a new attribute for the counter.
         */
-       if (inst->counter_name == NULL) {
+       if (!inst->counter_name) {
                radlog(L_ERR, "rlm_counter: 'counter-name' must be set.");
                return -1;
        }
@@ -421,7 +421,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        }
 
        dattr = dict_attrbyname(inst->counter_name);
-       if (dattr == NULL) {
+       if (!dattr) {
                radlog(L_ERR, "rlm_counter: Failed to find counter attribute %s",
                                inst->counter_name);
                return -1;
@@ -433,7 +433,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        /*
         * Create a new attribute for the check item.
         */
-       if (inst->check_name == NULL) {
+       if (!inst->check_name) {
                radlog(L_ERR, "rlm_counter: 'check-name' must be set.");
                return -1;
        }
@@ -444,7 +444,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
 
        }
        dattr = dict_attrbyname(inst->check_name);
-       if (dattr == NULL) {
+       if (!dattr) {
                radlog(L_ERR, "rlm_counter: Failed to find check attribute %s",
                                inst->counter_name);
                return -1;
@@ -466,7 +466,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        /*
         * Find when to reset the database.
         */
-       if (inst->reset == NULL) {
+       if (!inst->reset) {
                radlog(L_ERR, "rlm_counter: 'reset' must be set.");
                return -1;
        }
@@ -479,14 +479,14 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
                return -1;
        }
 
-       if (inst->filename == NULL) {
+       if (!inst->filename) {
                radlog(L_ERR, "rlm_counter: 'filename' must be set.");
                return -1;
        }
        inst->gdbm = gdbm_open(inst->filename, sizeof(int),
                               GDBM_WRCREAT | GDBM_COUNTER_OPTS,
                               0600, NULL);
-       if (inst->gdbm == NULL) {
+       if (!inst->gdbm) {
                radlog(L_ERR, "rlm_counter: Failed to open file %s: %s",
                                inst->filename, strerror(errno));
                return -1;
@@ -638,7 +638,7 @@ static rlm_rcode_t mod_accounting(void *instance, REQUEST *request)
         *      The REAL username, after stripping.
         */
        key_vp = (inst->key_attr == PW_USER_NAME) ? request->username : pairfind(request->packet->vps, inst->key_attr, 0, TAG_ANY);
-       if (key_vp == NULL){
+       if (!key_vp){
                DEBUG("rlm_counter: Could not find the key-attribute in the request. Returning NOOP.");
                return RLM_MODULE_NOOP;
        }
@@ -647,7 +647,7 @@ static rlm_rcode_t mod_accounting(void *instance, REQUEST *request)
         *      Look for the attribute to use as a counter.
         */
        count_vp = pairfind(request->packet->vps, inst->count_attr, 0, TAG_ANY);
-       if (count_vp == NULL){
+       if (!count_vp){
                DEBUG("rlm_counter: Could not find the count-attribute in the request.");
                return RLM_MODULE_NOOP;
        }
@@ -659,7 +659,7 @@ static rlm_rcode_t mod_accounting(void *instance, REQUEST *request)
        pthread_mutex_lock(&inst->mutex);
        count_datum = gdbm_fetch(inst->gdbm, key_datum);
        pthread_mutex_unlock(&inst->mutex);
-       if (count_datum.dptr == NULL){
+       if (!count_datum.dptr){
                DEBUG("rlm_counter: Could not find the requested key in the database.");
                counter.user_counter = 0;
                if (uniqueid_vp != NULL)
@@ -776,7 +776,7 @@ static rlm_rcode_t mod_authorize(void *instance, REQUEST *request)
         */
        DEBUG2("rlm_counter: Entering module authorize code");
        key_vp = (inst->key_attr == PW_USER_NAME) ? request->username : pairfind(request->packet->vps, inst->key_attr, 0, TAG_ANY);
-       if (key_vp == NULL) {
+       if (!key_vp) {
                DEBUG2("rlm_counter: Could not find Key value pair");
                return rcode;
        }
index 05f0adf..2f30794 100644 (file)
@@ -326,7 +326,7 @@ static rlm_rcode_t do_detail(void *instance, REQUEST *request, RADIUS_PACKET *pa
                gid = strtol(inst->group, &endptr, 10);
                if (*endptr != '\0') {
                        grp = getgrnam(inst->group);
-                       if (grp == NULL) {
+                       if (!grp) {
                                RDEBUG2("rlm_detail: Unable to find system group \"%s\"", inst->group);
                                goto skip_group;
                        }
index 56a9b09..b0fb915 100644 (file)
@@ -65,7 +65,7 @@ static size_t dhcp_options_xlat(UNUSED void *instance, REQUEST *request,
        
        if ((fr_dhcp_decode_options(request->packet,
                                    vp->vp_octets, vp->length, &head) < 0) ||
-           (head == NULL)) {
+           (!head)) {
                RDEBUGW("DHCP option decoding failed");
                goto fail;
        }
index 5431c58..893cfe1 100644 (file)
@@ -35,7 +35,7 @@ static int digest_fix(REQUEST *request)
         *      We need both of these attributes to do the authentication.
         */
        vp = pairfind(request->packet->vps, PW_DIGEST_RESPONSE, 0, TAG_ANY);
-       if (vp == NULL) {
+       if (!vp) {
                return RLM_MODULE_NOOP;
        }
 
@@ -50,7 +50,7 @@ static int digest_fix(REQUEST *request)
         *      We need these, too.
         */
        vp = pairfind(request->packet->vps, PW_DIGEST_ATTRIBUTES, 0, TAG_ANY);
-       if (vp == NULL) {
+       if (!vp) {
                return RLM_MODULE_NOOP;
        }
 
@@ -244,7 +244,7 @@ static rlm_rcode_t mod_authenticate(void *instance, REQUEST *request)
         *      We need these, too.
         */
        vp = pairfind(request->packet->vps, PW_DIGEST_ATTRIBUTES, 0, TAG_ANY);
-       if (vp == NULL) {
+       if (!vp) {
        error:
                RDEBUGE("You set 'Auth-Type = Digest' for a request that does not contain any digest attributes!");
                return RLM_MODULE_INVALID;
@@ -321,7 +321,7 @@ static rlm_rcode_t mod_authenticate(void *instance, REQUEST *request)
         *      Assume MD5 if no Digest-Algorithm attribute received
         */
        algo = pairfind(request->packet->vps, PW_DIGEST_ALGORITHM, 0, TAG_ANY);
-       if ((algo == NULL) ||
+       if ((!algo) ||
            (strcasecmp(algo->vp_strvalue, "MD5") == 0)) {
                /*
                 *      Set A1 to Digest-HA1 if no User-Password found
index 39af7fa..7d6b920 100644 (file)
@@ -398,7 +398,7 @@ eap_rcode_t eap_method_select(rlm_eap_t *inst, eap_handler_t *handler)
                 */
                if ((next < PW_EAP_MD5) ||
                    (next >= PW_EAP_MAX_TYPES) ||
-                   (inst->methods[next] == NULL)) {
+                   (!inst->methods[next])) {
                        RDEBUG2E("Tried to start unsupported method (%d)",
                                 next);
                        
@@ -660,7 +660,7 @@ int eap_start(rlm_eap_t *inst, REQUEST *request)
        VALUE_PAIR *eap_msg;
 
        eap_msg = pairfind(request->packet->vps, PW_EAP_MESSAGE, 0, TAG_ANY);
-       if (eap_msg == NULL) {
+       if (!eap_msg) {
                RDEBUG2("No EAP-Message, not doing EAP");
                return EAP_NOOP;
        }
@@ -694,7 +694,7 @@ int eap_start(rlm_eap_t *inst, REQUEST *request)
                 *      to it.
                 */
                realm = realm_find(proxy->vp_strvalue);
-               if (!realm || (realm && (realm->auth_pool == NULL))) {
+               if (!realm || (realm && (!realm->auth_pool))) {
                        proxy = NULL;
                }
        }
@@ -813,7 +813,7 @@ int eap_start(rlm_eap_t *inst, REQUEST *request)
            inst->ignore_unknown_types &&
            ((eap_msg->vp_octets[4] == 0) ||
             (eap_msg->vp_octets[4] >= PW_EAP_MAX_TYPES) ||
-            (inst->methods[eap_msg->vp_octets[4]] == NULL))) {
+            (!inst->methods[eap_msg->vp_octets[4]]))) {
                RDEBUG2(" Ignoring Unknown EAP type");
                return EAP_NOOP;
        }
@@ -838,7 +838,7 @@ int eap_start(rlm_eap_t *inst, REQUEST *request)
            inst->ignore_unknown_types &&
            ((eap_msg->vp_octets[5] == 0) ||
             (eap_msg->vp_octets[5] >= PW_EAP_MAX_TYPES) ||
-            (inst->methods[eap_msg->vp_octets[5]] == NULL))) {
+            (!inst->methods[eap_msg->vp_octets[5]]))) {
                RDEBUG2("Ignoring NAK with request for unknown EAP type");
                return EAP_NOOP;
        }
@@ -957,7 +957,7 @@ static char *eap_identity(REQUEST *request, eap_handler_t *handler, eap_packet_r
        uint16_t len;
        char *identity;
 
-       if ((eap_packet == NULL) ||
+       if ((!eap_packet) ||
            (eap_packet->code != PW_EAP_RESPONSE) ||
            (eap_packet->data[0] != PW_EAP_IDENTITY)) {
                return NULL;
@@ -1065,7 +1065,7 @@ eap_handler_t *eap_handler(rlm_eap_t *inst, eap_packet_raw_t **eap_packet_p,
         */
        if (eap_packet->data[0] != PW_EAP_IDENTITY) {
                handler = eaplist_find(inst, request, eap_packet);
-               if (handler == NULL) {
+               if (!handler) {
                        /* Either send EAP_Identity or EAP-Fail */
                        RDEBUG("Either EAP-request timed out OR"
                               " EAP-response to an unknown EAP-request");
@@ -1097,7 +1097,7 @@ eap_handler_t *eap_handler(rlm_eap_t *inst, eap_packet_raw_t **eap_packet_p,
                        */
                       RDEBUG2("Broken NAS did not set User-Name, setting from EAP Identity");
                       vp = pairmake(request->packet, NULL, "User-Name", handler->identity, T_OP_EQ);
-                      if (vp == NULL) {
+                      if (!vp) {
                               goto error;
                       }
                       vp->next = request->packet->vps;
@@ -1121,7 +1121,7 @@ eap_handler_t *eap_handler(rlm_eap_t *inst, eap_packet_raw_t **eap_packet_p,
               }
        } else {                /* packet was EAP identity */
                handler = eap_handler_alloc(inst);
-               if (handler == NULL) {
+               if (!handler) {
                        goto error;
                }
 
@@ -1129,7 +1129,7 @@ eap_handler_t *eap_handler(rlm_eap_t *inst, eap_packet_raw_t **eap_packet_p,
                 *      All fields in the handler are set to zero.
                 */
                handler->identity = eap_identity(request, handler, eap_packet);
-               if (handler->identity == NULL) {
+               if (!handler->identity) {
                        RDEBUG("Identity Unknown, authentication failed");
                error2:
                        eap_handler_free(inst, handler);
@@ -1147,7 +1147,7 @@ eap_handler_t *eap_handler(rlm_eap_t *inst, eap_packet_raw_t **eap_packet_p,
                        */
                       RDEBUG2W("NAS did not set User-Name.  Setting it locally from EAP Identity");
                       vp = pairmake(request->packet, NULL, "User-Name", handler->identity, T_OP_EQ);
-                      if (vp == NULL) {
+                      if (!vp) {
                               goto error2;
                       }
                       vp->next = request->packet->vps;
@@ -1168,7 +1168,7 @@ eap_handler_t *eap_handler(rlm_eap_t *inst, eap_packet_raw_t **eap_packet_p,
        }
 
        handler->eap_ds = eap_buildds(handler, eap_packet_p);
-       if (handler->eap_ds == NULL) {
+       if (!handler->eap_ds) {
                goto error2;
        }
 
index ad34735..9885df1 100644 (file)
@@ -342,7 +342,7 @@ static fr_tls_status_t eaptls_verify(eap_handler_t *handler)
         *
         *      Find if this is a reply to the previous request sent
         */
-       if ((eaptls_packet == NULL) ||
+       if ((!eaptls_packet) ||
            ((eap_ds->response->length == EAP_HEADER_LEN + 2) &&
             ((eaptls_packet->flags & 0xc0) == 0x00))) {
 
@@ -391,8 +391,8 @@ static fr_tls_status_t eaptls_verify(eap_handler_t *handler)
                         *      (It is because Last fragment will not have M bit set)
                         */
                        if (!prev_eap_ds ||
-                           (prev_eap_ds->response == NULL) ||
-                           (eaptls_prev == NULL) ||
+                           (!prev_eap_ds->response) ||
+                           (!eaptls_prev) ||
                            !TLS_MORE_FRAGMENTS(eaptls_prev->flags)) {
 
                                RDEBUG2("Received EAP-TLS First Fragment of the message");
@@ -480,7 +480,7 @@ static EAPTLS_PACKET *eaptls_extract(REQUEST *request, EAP_DS *eap_ds, fr_tls_st
        assert(eap_ds->response->length > 2);
 
        tlspacket = talloc(eap_ds, EAPTLS_PACKET);
-       if (tlspacket == NULL) return NULL;
+       if (!tlspacket) return NULL;
 
        /*
         *      Code & id for EAPTLS & EAP are same
@@ -591,7 +591,7 @@ static EAPTLS_PACKET *eaptls_extract(REQUEST *request, EAP_DS *eap_ds, fr_tls_st
        if (data_len) {
                tlspacket->data = talloc_array(tlspacket, uint8_t,
                                               data_len);
-               if (tlspacket->data == NULL) {
+               if (!tlspacket->data) {
                        talloc_free(tlspacket);
                        return NULL;
                }
@@ -883,7 +883,7 @@ int eaptls_compose(EAP_DS *eap_ds, EAPTLS_PACKET *reply)
         */
        eap_ds->request->type.data = talloc_array(eap_ds->request, uint8_t,
                                                  reply->length - TLS_HEADER_LEN + 1);
-       if (eap_ds->request->type.data == NULL) {
+       if (!eap_ds->request->type.data) {
                return 0;
        }
 
index 96389b8..3ea6a20 100644 (file)
@@ -130,7 +130,7 @@ int eap_wireformat(eap_packet_t *reply)
        eap_packet_raw_t        *header;
        uint16_t total_length = 0;
 
-       if (reply == NULL) return EAP_INVALID;
+       if (!reply) return EAP_INVALID;
 
        /*
         *      If reply->packet is set, then the wire format
@@ -301,7 +301,7 @@ eap_packet_raw_t *eap_vp2packet(TALLOC_CTX *ctx, VALUE_PAIR *vps)
         *      Get only EAP-Message attribute list
         */
        first = pairfind(vps, PW_EAP_MESSAGE, 0, TAG_ANY);
-       if (first == NULL) {
+       if (!first) {
                DEBUG("rlm_eap: EAP-Message not found");
                return NULL;
        }
@@ -354,7 +354,7 @@ eap_packet_raw_t *eap_vp2packet(TALLOC_CTX *ctx, VALUE_PAIR *vps)
         *      Now that we know the lengths are OK, allocate memory.
         */
        eap_packet = (eap_packet_raw_t *) talloc_zero_array(ctx, uint8_t, len);
-       if (eap_packet == NULL) {
+       if (!eap_packet) {
                return NULL;
        }
 
index 515786d..e15b2aa 100644 (file)
@@ -81,7 +81,7 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, eap_packet_t *ep)
         *
         */
        vp = pairfind(r->vps, ATTRIBUTE_EAP_SIM_SUBTYPE, 0, TAG_ANY);
-       if(vp == NULL)
+       if(!vp)
        {
                subtype = eapsim_start;
        }
@@ -91,7 +91,7 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, eap_packet_t *ep)
        }
 
        vp = pairfind(r->vps, ATTRIBUTE_EAP_ID, 0, TAG_ANY);
-       if(vp == NULL)
+       if(!vp)
        {
                id = ((int)getpid() & 0xff);
        }
@@ -101,7 +101,7 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, eap_packet_t *ep)
        }
 
        vp = pairfind(r->vps, ATTRIBUTE_EAP_CODE, 0, TAG_ANY);
-       if(vp == NULL)
+       if(!vp)
        {
                eapcode = PW_EAP_REQUEST;
        }
@@ -188,7 +188,7 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, eap_packet_t *ep)
 
        encoded_size += 3;
        encodedmsg = talloc_array(ep, uint8_t, encoded_size);
-       if (encodedmsg == NULL) {
+       if (!encodedmsg) {
                return 0;
        }
        memset(encodedmsg, 0, encoded_size);
@@ -292,7 +292,7 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, eap_packet_t *ep)
        }
 
        /* if we had an AT_MAC and no key, then fail */
-       if(macspace != NULL && vp == NULL)
+       if(macspace != NULL && !vp)
        {
                if(encodedmsg != NULL)
                        talloc_free(encodedmsg);
@@ -395,7 +395,7 @@ eapsim_checkmac(TALLOC_CTX *ctx, VALUE_PAIR *rvps,
 
        mac = pairfind(rvps, ATTRIBUTE_EAP_SIM_BASE+PW_EAP_SIM_MAC, 0, TAG_ANY);
 
-       if(mac == NULL
+       if(!mac
           || mac->length != 18) {
                /* can't check a packet with no AT_MAC attribute */
                return 0;
index 61c3c77..ae83844 100644 (file)
@@ -400,7 +400,7 @@ static int process_eap_start(RADIUS_PACKET *req,
        fullauthidreq_vp = pairfind(req->vps, ATTRIBUTE_EAP_SIM_BASE+PW_EAP_SIM_FULLAUTH_ID_REQ, 0, TAG_ANY);
        permanentidreq_vp = pairfind(req->vps, ATTRIBUTE_EAP_SIM_BASE+PW_EAP_SIM_PERMANENT_ID_REQ, 0, TAG_ANY);
 
-       if(fullauthidreq_vp == NULL ||
+       if(!fullauthidreq_vp ||
           anyidreq_vp != NULL ||
           permanentidreq_vp != NULL) {
                fprintf(stderr, "start message has %sanyidreq, %sfullauthid and %spermanentid. Illegal combination.\n",
@@ -459,7 +459,7 @@ static int process_eap_start(RADIUS_PACKET *req,
                 * insert the identity here.
                 */
                vp = pairfind(rep->vps, PW_USER_NAME, 0, TAG_ANY);
-               if(vp == NULL)
+               if(!vp)
                {
                        fprintf(stderr, "eap-sim: We need to have a User-Name attribute!\n");
                        return 0;
@@ -504,7 +504,7 @@ static int process_eap_challenge(RADIUS_PACKET *req,
        /* look for the AT_MAC and the challenge data */
        mac   = pairfind(req->vps, ATTRIBUTE_EAP_SIM_BASE+PW_EAP_SIM_MAC, 0, TAG_ANY);
        randvp= pairfind(req->vps, ATTRIBUTE_EAP_SIM_BASE+PW_EAP_SIM_RAND, 0, TAG_ANY);
-       if(mac == NULL || randvp == NULL) {
+       if(!mac || !randvp) {
                fprintf(stderr, "radeapclient: challenge message needs to contain RAND and MAC\n");
                return 0;
        }
@@ -525,9 +525,9 @@ static int process_eap_challenge(RADIUS_PACKET *req,
          randcfgvp[1] = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_RAND2, 0, TAG_ANY);
          randcfgvp[2] = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_RAND3, 0, TAG_ANY);
 
-         if(randcfgvp[0] == NULL ||
-            randcfgvp[1] == NULL ||
-            randcfgvp[2] == NULL) {
+         if(!randcfgvp[0] ||
+            !randcfgvp[1] ||
+            !randcfgvp[2]) {
            fprintf(stderr, "radeapclient: needs to have rand1, 2 and 3 set.\n");
            return 0;
          }
@@ -578,9 +578,9 @@ static int process_eap_challenge(RADIUS_PACKET *req,
        sres2 = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_SRES2, 0, TAG_ANY);
        sres3 = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_SRES3, 0, TAG_ANY);
 
-       if(sres1 == NULL ||
-          sres2 == NULL ||
-          sres3 == NULL) {
+       if(!sres1 ||
+          !sres2 ||
+          !sres3) {
                fprintf(stderr, "radeapclient: needs to have sres1, 2 and 3 set.\n");
                return 0;
        }
@@ -592,9 +592,9 @@ static int process_eap_challenge(RADIUS_PACKET *req,
        Kc2 = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_KC2, 0, TAG_ANY);
        Kc3 = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_KC3, 0, TAG_ANY);
 
-       if(Kc1 == NULL ||
-          Kc2 == NULL ||
-          Kc3 == NULL) {
+       if(!Kc1 ||
+          !Kc2 ||
+          !Kc3) {
                fprintf(stderr, "radeapclient: needs to have Kc1, 2 and 3 set.\n");
                return 0;
        }
@@ -1086,7 +1086,7 @@ int main(int argc, char **argv)
        argv += (optind - 1);
 
        if ((argc < 3)  ||
-           ((secret == NULL) && (argc < 4))) {
+           ((!secret) && (argc < 4))) {
                usage();
        }
 
@@ -1262,14 +1262,14 @@ static void map_eap_methods(RADIUS_PACKET *req)
        int eap_method;
 
        vp = pairfind(req->vps, ATTRIBUTE_EAP_ID, 0, TAG_ANY);
-       if(vp == NULL) {
+       if(!vp) {
                id = ((int)getpid() & 0xff);
        } else {
                id = vp->vp_integer;
        }
 
        vp = pairfind(req->vps, ATTRIBUTE_EAP_CODE, 0, TAG_ANY);
-       if(vp == NULL) {
+       if(!vp) {
                eapcode = PW_EAP_REQUEST;
        } else {
                eapcode = vp->vp_integer;
@@ -1286,7 +1286,7 @@ static void map_eap_methods(RADIUS_PACKET *req)
                }
        }
 
-       if(vp == NULL) {
+       if(!vp) {
                return;
        }
 
@@ -1337,7 +1337,7 @@ static void unmap_eap_methods(RADIUS_PACKET *rep)
        e = eap_vp2packet(NULL, rep->vps);
 
        /* nothing to do! */
-       if(e == NULL) return;
+       if(!e) return;
 
        /* create EAP-ID and EAP-CODE attributes to start */
        eap1 = paircreate(rep, ATTRIBUTE_EAP_ID, 0, PW_TYPE_INTEGER);
@@ -1414,7 +1414,7 @@ static int unmap_eapsim_types(RADIUS_PACKET *r)
        VALUE_PAIR           *esvp;
 
        esvp = pairfind(r->vps, ATTRIBUTE_EAP_BASE+PW_EAP_SIM, 0, TAG_ANY);
-       if (esvp == NULL) {
+       if (!esvp) {
                radlog(L_ERR, "eap: EAP-Sim attribute not found");
                return 0;
        }
@@ -1497,7 +1497,7 @@ main(int argc, char *argv[])
                /* find the EAP-Message, copy it to req2 */
                vp = paircopy2(NULL, req->vps, PW_EAP_MESSAGE, 0, TAG_ANY);
 
-               if(vp == NULL) continue;
+               if(!vp) continue;
 
                pairadd(&req2->vps, vp);
 
index 3176ff1..94e94ff 100644 (file)
@@ -228,7 +228,7 @@ static int mod_instantiate(CONF_SECTION *cs, void **instance)
                return -1;
        }
 
-       if (inst->methods[method] == NULL) {
+       if (!inst->methods[method]) {
                radlog(L_ERR, "rlm_eap (%s): No such sub-type for default EAP method %s", inst->xlat_name,
                       inst->default_method_name);
                mod_detach(inst);
@@ -309,7 +309,7 @@ static rlm_rcode_t mod_authenticate(void *instance, REQUEST *request)
         *      Get the eap packet  to start with
         */
        eap_packet = eap_vp2packet(request, request->packet->vps);
-       if (eap_packet == NULL) {
+       if (!eap_packet) {
                radlog_request(L_ERR, 0, request, "Malformed EAP Message");
                return RLM_MODULE_FAIL;
        }
@@ -320,7 +320,7 @@ static rlm_rcode_t mod_authenticate(void *instance, REQUEST *request)
         *      this call.
         */
        handler = eap_handler(inst, &eap_packet, request);
-       if (handler == NULL) {
+       if (!handler) {
                RDEBUG2("Failed in handler");
                return RLM_MODULE_INVALID;
        }
@@ -369,7 +369,7 @@ static rlm_rcode_t mod_authenticate(void *instance, REQUEST *request)
        if (request->proxy != NULL) {
                VALUE_PAIR *vp = NULL;
 
-               rad_assert(request->proxy_reply == NULL);
+               rad_assert(!request->proxy_reply);
 
                /*
                 *      Add the handle to the proxied list, so that we
@@ -754,13 +754,13 @@ static rlm_rcode_t mod_post_auth(void *instance, REQUEST *request)
        }
        
        eap_packet = eap_vp2packet(request, request->packet->vps);
-       if (eap_packet == NULL) {
+       if (!eap_packet) {
                radlog_request(L_ERR, 0, request, "Malformed EAP Message");
                return RLM_MODULE_FAIL;
        }
 
        handler = eap_handler(inst, &eap_packet, request);
-       if (handler == NULL) {
+       if (!handler) {
                RDEBUG2("Failed to get handler, probably already removed, not inserting EAP-Failure");
                return RLM_MODULE_NOOP;
        }
index e638f0d..4817eeb 100644 (file)
@@ -107,7 +107,7 @@ static int gtc_initiate(void *instance, eap_handler_t *handler)
 
        eap_ds->request->type.data = talloc_array(eap_ds->request,
                                                  uint8_t, length);
-       if (eap_ds->request->type.data == NULL) {
+       if (!eap_ds->request->type.data) {
                return 0;
        }
 
index b110e9b..9161116 100644 (file)
@@ -80,7 +80,7 @@ static int ComposeRadMsg(uint8_t *out,u_int32_t olen, EAP_DS *eap_ds){
            int len=(int)ntohs(((struct EAPHeader *)out)->Length);
            eap_ds->request->type.data = talloc_array(eap_ds->request,
                                                      uint8_t, len);
-           if (eap_ds->request->type.data == NULL) {
+           if (!eap_ds->request->type.data) {
                return 1;
            }
            memcpy(eap_ds->request->type.data,out+5,len-5);
@@ -191,7 +191,7 @@ static int ikev2_attach(CONF_SECTION *conf, void **instance)
 
 
     i2 = Create_ikev2_ctx();
-    if (i2 == NULL) {
+    if (!i2) {
        return -1;
     }
     *instance =i2;
index 8c2c819..3a51866 100644 (file)
@@ -130,7 +130,7 @@ leap_packet_t *eapleap_extract(EAP_DS *eap_ds)
        packet->count = data->count;
 
        packet->challenge = talloc_array(packet, uint8_t, packet->count);
-       if (packet->challenge == NULL) {
+       if (!packet->challenge) {
                talloc_free(packet);
                return NULL;
        }
@@ -216,7 +216,7 @@ int eapleap_stage4(leap_packet_t *packet, VALUE_PAIR* password,
        /*
         *      No password or previous packet.  Die.
         */
-       if ((password == NULL) || (session == NULL)) {
+       if ((!password) || (!session)) {
                return 0;
        }
 
@@ -255,7 +255,7 @@ leap_packet_t *eapleap_stage6(leap_packet_t *packet, REQUEST *request,
        /*
         *      No password or previous packet.  Die.
         */
-       if ((password == NULL) || (session == NULL)) {
+       if ((!password) || (!session)) {
                return NULL;
        }
 
@@ -267,7 +267,7 @@ leap_packet_t *eapleap_stage6(leap_packet_t *packet, REQUEST *request,
        reply->count = 24;
 
        reply->challenge = talloc_array(reply, uint8_t, reply->count);
-       if (reply->challenge == NULL) {
+       if (!reply->challenge) {
                talloc_free(reply);
                return NULL;
        }
@@ -276,7 +276,7 @@ leap_packet_t *eapleap_stage6(leap_packet_t *packet, REQUEST *request,
         *      The LEAP packet also contains the user name.
         */
        reply->name = talloc_array(reply, char, user_name->length + 1);
-       if (reply->name == NULL) {
+       if (!reply->name) {
                talloc_free(reply);
                return NULL;
        }
@@ -354,7 +354,7 @@ leap_packet_t *eapleap_initiate(EAP_DS *eap_ds, VALUE_PAIR *user_name)
        leap_packet_t   *reply;
 
        reply = talloc(eap_ds, leap_packet_t);
-       if (reply == NULL)  {
+       if (!reply)  {
                return NULL;
        }
 
@@ -363,7 +363,7 @@ leap_packet_t *eapleap_initiate(EAP_DS *eap_ds, VALUE_PAIR *user_name)
        reply->count = 8;       /* random challenge */
 
        reply->challenge = talloc_array(reply, uint8_t, reply->count);
-       if (reply->challenge == NULL) {
+       if (!reply->challenge) {
                talloc_free(reply);
                return NULL;
        }
@@ -381,7 +381,7 @@ leap_packet_t *eapleap_initiate(EAP_DS *eap_ds, VALUE_PAIR *user_name)
         *      The LEAP packet also contains the user name.
         */
        reply->name = talloc_array(reply, char, user_name->length + 1);
-       if (reply->name == NULL) {
+       if (!reply->name) {
                talloc_free(reply);
                return NULL;
        }
@@ -415,7 +415,7 @@ int eapleap_compose(EAP_DS *eap_ds, leap_packet_t *reply)
                eap_ds->request->type.data = talloc_array(eap_ds->request,
                                                          uint8_t,
                                                          reply->length);
-               if (eap_ds->request->type.data == NULL) {
+               if (!eap_ds->request->type.data) {
                        return 0;
                }
                data = (leap_packet_raw_t *) eap_ds->request->type.data;
index fa94543..793da16 100644 (file)
@@ -54,7 +54,7 @@ static int leap_initiate(UNUSED void *instance, eap_handler_t *handler)
        }
 
        reply = eapleap_initiate(handler->eap_ds, handler->request->username);
-       if (reply == NULL)
+       if (!reply)
                return 0;
 
        eapleap_compose(handler->eap_ds, reply);
index c1198e5..43ae171 100644 (file)
@@ -98,7 +98,7 @@ MD5_PACKET *eapmd5_extract(EAP_DS *eap_ds)
         *      Allocate room for the data, and copy over the data.
         */
        packet->value = talloc_array(packet, uint8_t, packet->value_size);
-       if (packet->value == NULL) {
+       if (!packet->value) {
                talloc_free(packet);
                return NULL;
        }
@@ -193,7 +193,7 @@ int eapmd5_compose(EAP_DS *eap_ds, MD5_PACKET *reply)
                eap_ds->request->type.data = talloc_array(eap_ds->request,
                                                          uint8_t,
                                                          reply->length);
-               if (eap_ds->request->type.data == NULL) {
+               if (!eap_ds->request->type.data) {
                        talloc_free(reply);
                        return 0;
                }
index 3a1c671..8d0ba49 100644 (file)
@@ -45,7 +45,7 @@ static int md5_initiate(void *instance, eap_handler_t *handler)
         *      Allocate an EAP-MD5 packet.
         */
        reply = talloc(handler, MD5_PACKET);
-       if (reply == NULL)  {
+       if (!reply)  {
                return 0;
        }
 
@@ -60,7 +60,7 @@ static int md5_initiate(void *instance, eap_handler_t *handler)
         *      Allocate user data.
         */
        reply->value = talloc_array(reply, uint8_t, reply->value_size);
-       if (reply->value == NULL) {
+       if (!reply->value) {
                talloc_free(reply);
                return 0;
        }
@@ -116,7 +116,7 @@ static int md5_authenticate(UNUSED void *arg, eap_handler_t *handler)
        rad_assert(handler->stage == AUTHENTICATE);
 
        password = pairfind(handler->request->config_items, PW_CLEARTEXT_PASSWORD, 0, TAG_ANY);
-       if (password == NULL) {
+       if (!password) {
                DEBUG2("rlm_eap_md5: Cleartext-Password is required for EAP-MD5 authentication");
                return 0;
        }
index f9564e7..b59adae 100644 (file)
@@ -124,7 +124,7 @@ static int eapmschapv2_compose(eap_handler_t *handler, VALUE_PAIR *reply)
                /*
                 *      Allocate room for the EAP-MS-CHAPv2 data.
                 */
-               if (eap_ds->request->type.data == NULL) {
+               if (!eap_ds->request->type.data) {
                        return 0;
                }
                eap_ds->request->type.length = length;
@@ -166,7 +166,7 @@ static int eapmschapv2_compose(eap_handler_t *handler, VALUE_PAIR *reply)
                /*
                 *      Allocate room for the EAP-MS-CHAPv2 data.
                 */
-               if (eap_ds->request->type.data == NULL) {
+               if (!eap_ds->request->type.data) {
                        return 0;
                }
                memset(eap_ds->request->type.data, 0, length);
@@ -188,7 +188,7 @@ static int eapmschapv2_compose(eap_handler_t *handler, VALUE_PAIR *reply)
                /*
                 *      Allocate room for the EAP-MS-CHAPv2 data.
                 */
-               if (eap_ds->request->type.data == NULL) {
+               if (!eap_ds->request->type.data) {
                        return 0;
                }
                memset(eap_ds->request->type.data, 0, length);
index 18be008..b046dd9 100644 (file)
@@ -459,9 +459,9 @@ static int process_reply(eap_handler_t *handler, tls_session_t *tls_session,
                        pairdelete(&reply->vps, 16, VENDORPEC_MICROSOFT, TAG_ANY);
                        pairdelete(&reply->vps, 17, VENDORPEC_MICROSOFT, TAG_ANY);
 
-                       rad_assert(t->accept_vps == NULL);
+                       rad_assert(!t->accept_vps);
                        pairfilter(t, &t->accept_vps, &reply->vps, 0, 0, TAG_ANY);
-                       rad_assert(reply->vps == NULL);
+                       rad_assert(!reply->vps);
                }
                break;
 
@@ -507,10 +507,10 @@ static int process_reply(eap_handler_t *handler, tls_session_t *tls_session,
                        pairdelete(&reply->vps, PW_PROXY_STATE, 0, TAG_ANY);
                        pairdelete(&reply->vps, PW_MESSAGE_AUTHENTICATOR, 0, TAG_ANY);
 
-                       rad_assert(t->accept_vps == NULL);
+                       rad_assert(!t->accept_vps);
                        pairfilter(t, &t->accept_vps, &reply->vps,
                                  0, 0, TAG_ANY);
-                       rad_assert(reply->vps == NULL);
+                       rad_assert(!reply->vps);
                }
 
                /*
@@ -566,12 +566,12 @@ static int eappeap_postproxy(eap_handler_t *handler, void *data)
                /*
                 *      Terrible hacks.
                 */
-               rad_assert(fake->packet == NULL);
+               rad_assert(!fake->packet);
                fake->packet = request->proxy;
                fake->packet->src_ipaddr = request->packet->src_ipaddr;
                request->proxy = NULL;
 
-               rad_assert(fake->reply == NULL);
+               rad_assert(!fake->reply);
                fake->reply = request->proxy_reply;
                request->proxy_reply = NULL;
 
@@ -626,7 +626,7 @@ static int eappeap_postproxy(eap_handler_t *handler, void *data)
                        break;
                }
        }
-       request_free(&fake);    /* robust if fake == NULL */
+       request_free(&fake);    /* robust if !fake */
 
        /*
         *      If there was no EAP-Message in the reply packet, then
@@ -820,7 +820,7 @@ int eappeap_process(eap_handler_t *handler, tls_session_t *tls_session)
 
        case PEAP_STATUS_WAIT_FOR_SOH_RESPONSE:
                fake = request_alloc_fake(request);
-               rad_assert(fake->packet->vps == NULL);
+               rad_assert(!fake->packet->vps);
                eapsoh_verify(request, fake->packet, data, data_len);
                setup_fake_request(request, fake, t);
 
@@ -844,9 +844,9 @@ int eappeap_process(eap_handler_t *handler, tls_session_t *tls_session)
                }
 
                /* save the SoH VPs */
-               rad_assert(t->soh_reply_vps == NULL);
+               rad_assert(!t->soh_reply_vps);
                pairfilter(t, &t->soh_reply_vps, &fake->reply->vps, 0, 0, TAG_ANY);
-               rad_assert(fake->reply->vps == NULL);
+               rad_assert(!fake->reply->vps);
                request_free(&fake);
 
                if (t->session_resumption_state == PEAP_RESUMPTION_YES) {
@@ -918,7 +918,7 @@ int eappeap_process(eap_handler_t *handler, tls_session_t *tls_session)
 
        fake = request_alloc_fake(request);
 
-       rad_assert(fake->packet->vps == NULL);
+       rad_assert(!fake->packet->vps);
 
        switch (t->status) {
                /*
@@ -975,7 +975,7 @@ int eappeap_process(eap_handler_t *handler, tls_session_t *tls_session)
                debug_pair_list(fake->packet->vps);
 
                fprintf(fr_log_fp, "server %s {\n",
-                       (fake->server == NULL) ? "" : fake->server);
+                       (!fake->server) ? "" : fake->server);
        }
 
        /*
@@ -1024,7 +1024,7 @@ int eappeap_process(eap_handler_t *handler, tls_session_t *tls_session)
                debug_pair_list(fake->packet->vps);
 
                fprintf(fr_log_fp, "server %s {\n",
-                       (fake->server == NULL) ? "" : fake->server);
+                       (!fake->server) ? "" : fake->server);
        }
 
        /*
@@ -1039,7 +1039,7 @@ int eappeap_process(eap_handler_t *handler, tls_session_t *tls_session)
         */
        if ((debug_flag > 0) && fr_log_fp) {
                fprintf(fr_log_fp, "} # server %s\n",
-                       (fake->server == NULL) ? "" : fake->server);
+                       (!fake->server) ? "" : fake->server);
 
                RDEBUG("Got tunneled reply code %d", fake->reply->code);
                
@@ -1132,7 +1132,7 @@ int eappeap_process(eap_handler_t *handler, tls_session_t *tls_session)
                         *      Seed the proxy packet with the
                         *      tunneled request.
                         */
-                       rad_assert(request->proxy == NULL);
+                       rad_assert(!request->proxy);
                        request->proxy = fake->packet;
                        memset(&request->proxy->src_ipaddr, 0,
                               sizeof(request->proxy->src_ipaddr));
index 2f68e9a..bcd3cc1 100644 (file)
@@ -95,7 +95,7 @@ free_session (void *data)
 {
     pwd_session_t *session = (pwd_session_t *)data;
 
-    if (session == NULL) {
+    if (!session) {
        radlog(L_ERR, "rlm_eap_pwd: freeing a NULL session...naughty, naughty");
        return;
     }
@@ -193,7 +193,7 @@ eap_pwd_initiate (void *instance, eap_handler_t *handler)
     /*
      * make sure the server's been configured properly
      */
-    if (inst->conf->server_id == NULL) {
+    if (!inst->conf->server_id) {
        radlog(L_ERR, "rlm_eap_pwd: server ID is not configured!");
        return -1;
     }
@@ -288,9 +288,9 @@ mod_authenticate (void *arg, eap_handler_t *handler)
     uint8_t peer_confirm[SHA256_DIGEST_LENGTH];
     BIGNUM *x = NULL, *y = NULL;
 
-    if ((handler == NULL) ||
+    if ((!handler) ||
        ((eap_ds = handler->eap_ds) == NULL) ||
-       (inst == NULL)) {
+       (!inst)) {
        return 0;
     }
     pwd_session = (pwd_session_t *)handler->opaque;
@@ -442,7 +442,7 @@ mod_authenticate (void *arg, eap_handler_t *handler)
                    debug_pair_list(fake->packet->vps);
                
                    fprintf(fr_log_fp, "server %s {\n",
-                           (fake->server == NULL) ? "" : fake->server);
+                           (!fake->server) ? "" : fake->server);
            }
        
            /*
@@ -457,7 +457,7 @@ mod_authenticate (void *arg, eap_handler_t *handler)
             */
            if ((debug_flag > 0) && fr_log_fp) {
                    fprintf(fr_log_fp, "} # server %s\n",
-                           (fake->server == NULL) ? "" : fake->server);
+                           (!fake->server) ? "" : fake->server);
                
                    RDEBUG("Got tunneled reply code %d", fake->reply->code);
                
index 62dfc1c..5afafec 100644 (file)
@@ -118,7 +118,7 @@ static int eap_sim_getchalans(VALUE_PAIR *vps, int chalno,
        rad_assert(chalno >= 0 && chalno < 3);
 
        vp = pairfind(vps, ATTRIBUTE_EAP_SIM_RAND1+chalno, 0, TAG_ANY);
-       if(vp == NULL) {
+       if(!vp) {
                /* bad, we can't find stuff! */
                DEBUG2("   eap-sim can not find sim-challenge%d",chalno+1);
                return 0;
@@ -131,7 +131,7 @@ static int eap_sim_getchalans(VALUE_PAIR *vps, int chalno,
        memcpy(ess->keys.rand[chalno], vp->vp_strvalue, EAPSIM_RAND_SIZE);
 
        vp = pairfind(vps, ATTRIBUTE_EAP_SIM_SRES1+chalno, 0, TAG_ANY);
-       if(vp == NULL) {
+       if(!vp) {
                /* bad, we can't find stuff! */
                DEBUG2("   eap-sim can not find sim-sres%d",chalno+1);
                return 0;
@@ -144,7 +144,7 @@ static int eap_sim_getchalans(VALUE_PAIR *vps, int chalno,
        memcpy(ess->keys.sres[chalno], vp->vp_strvalue, EAPSIM_SRES_SIZE);
 
        vp = pairfind(vps, ATTRIBUTE_EAP_SIM_KC1+chalno, 0, TAG_ANY);
-       if(vp == NULL) {
+       if(!vp) {
                /* bad, we can't find stuff! */
                DEBUG2("   eap-sim can not find sim-kc%d",chalno+1);
                return 0;
@@ -361,13 +361,13 @@ static int eap_sim_initiate(void *instance, eap_handler_t *handler)
        instance = instance;  /* shut up compiler */
 
        vp = pairfind(outvps, ATTRIBUTE_EAP_SIM_RAND1, 0, TAG_ANY);
-       if(vp == NULL) {
+       if(!vp) {
                DEBUG2("   can not initiate sim, no RAND1 attribute");
                return 0;
        }
 
        ess = talloc_zero(handler, struct eap_sim_server_state);
-       if(ess == NULL) {
+       if(!ess) {
                DEBUG2("   no space for eap sim state");
                return 0;
        }
@@ -422,8 +422,8 @@ static int process_eap_sim_start(eap_handler_t *handler, VALUE_PAIR *vps)
        nonce_vp = pairfind(vps, ATTRIBUTE_EAP_SIM_BASE+PW_EAP_SIM_NONCE_MT, 0, TAG_ANY);
        selectedversion_vp = pairfind(vps, ATTRIBUTE_EAP_SIM_BASE+PW_EAP_SIM_SELECTED_VERSION, 0, TAG_ANY);
 
-       if(nonce_vp == NULL ||
-          selectedversion_vp == NULL) {
+       if(!nonce_vp ||
+          !selectedversion_vp) {
                DEBUG2("   client did not select a version and send a NONCE");
                eap_sim_stateenter(handler, ess, eapsim_server_start);
                return 1;
index b134d05..4f5546a 100644 (file)
@@ -159,7 +159,7 @@ static int mod_authenticate(void *type_arg, eap_handler_t *handler)
 
                        /* create a fake request */
                        fake = request_alloc_fake(request);
-                       rad_assert(fake->packet->vps == NULL);
+                       rad_assert(!fake->packet->vps);
 
                        fake->packet->vps = paircopy(fake->packet, request->packet->vps);
 
index 7b018eb..895af22 100644 (file)
@@ -717,10 +717,10 @@ static int process_reply(eap_handler_t *handler, tls_session_t *tls_session,
                         *      Use the tunneled reply, but not now.
                         */
                        if (t->use_tunneled_reply) {
-                               rad_assert(t->accept_vps == NULL);
+                               rad_assert(!t->accept_vps);
                                pairfilter(t, &t->accept_vps, &reply->vps,
                                          0, 0, TAG_ANY);
-                               rad_assert(reply->vps == NULL);
+                               rad_assert(!reply->vps);
                        }
 
                } else { /* no MS-CHAP2-Success */
@@ -854,18 +854,18 @@ static int eapttls_postproxy(eap_handler_t *handler, void *data)
                /*
                 *      Terrible hacks.
                 */
-               rad_assert(fake->packet == NULL);
+               rad_assert(!fake->packet);
                fake->packet = request->proxy;
                fake->packet->src_ipaddr = request->packet->src_ipaddr;
                request->proxy = NULL;
 
-               rad_assert(fake->reply == NULL);
+               rad_assert(!fake->reply);
                fake->reply = request->proxy_reply;
                request->proxy_reply = NULL;
 
                if ((debug_flag > 0) && fr_log_fp) {
                        fprintf(fr_log_fp, "server %s {\n",
-                               (fake->server == NULL) ? "" : fake->server);
+                               (!fake->server) ? "" : fake->server);
                }
 
                /*
@@ -878,7 +878,7 @@ static int eapttls_postproxy(eap_handler_t *handler, void *data)
 
                if ((debug_flag > 0) && fr_log_fp) {
                        fprintf(fr_log_fp, "} # server %s\n",
-                               (fake->server == NULL) ? "" : fake->server);
+                               (!fake->server) ? "" : fake->server);
                        
                        RDEBUG("Final reply from tunneled session code %d",
                               fake->reply->code);
@@ -910,7 +910,7 @@ static int eapttls_postproxy(eap_handler_t *handler, void *data)
                        break;
                }
        }
-       request_free(&fake);    /* robust if fake == NULL */
+       request_free(&fake);    /* robust if !fake */
 
        /*
         *      Process the reply from the home server.
@@ -1031,7 +1031,7 @@ int eapttls_process(eap_handler_t *handler, tls_session_t *tls_session)
         */
        fake = request_alloc_fake(request);
 
-       rad_assert(fake->packet->vps == NULL);
+       rad_assert(!fake->packet->vps);
 
        /*
         *      Add the tunneled attributes to the fake request.
@@ -1209,7 +1209,7 @@ int eapttls_process(eap_handler_t *handler, tls_session_t *tls_session)
                debug_pair_list(fake->packet->vps);
 
                fprintf(fr_log_fp, "server %s {\n",
-                       (fake->server == NULL) ? "" : fake->server);
+                       (!fake->server) ? "" : fake->server);
        }
 
        /*
@@ -1224,7 +1224,7 @@ int eapttls_process(eap_handler_t *handler, tls_session_t *tls_session)
         */
        if ((debug_flag > 0) && fr_log_fp) {
                fprintf(fr_log_fp, "} # server %s\n",
-                       (fake->server == NULL) ? "" : fake->server);
+                       (!fake->server) ? "" : fake->server);
 
                RDEBUG("Got tunneled reply code %d", fake->reply->code);
                
@@ -1254,7 +1254,7 @@ int eapttls_process(eap_handler_t *handler, tls_session_t *tls_session)
                         *      Seed the proxy packet with the
                         *      tunneled request.
                         */
-                       rad_assert(request->proxy == NULL);
+                       rad_assert(!request->proxy);
                        request->proxy = fake->packet;
                        memset(&request->proxy->src_ipaddr, 0,
                               sizeof(request->proxy->src_ipaddr));
index cb51fb9..e40f6ad 100644 (file)
@@ -498,7 +498,7 @@ static int eap_example_server_init_tls(rlm_eap_t *inst)
 
        os_memset(&tconf, 0, sizeof(tconf));
        inst->tls_ctx = tls_init(&tconf);
-       if (inst->tls_ctx == NULL)
+       if (!inst->tls_ctx)
                return -1;
 
        if (tls_global_set_params(inst->tls_ctx, &inst->tparams)) {
@@ -767,7 +767,7 @@ static int eap_vp2data(VALUE_PAIR *vps, void **data, int *data_len)
         *      Get only EAP-Message attribute list
         */
        first = pairfind(vps, PW_EAP_MESSAGE, 0, TAG_ANY);
-       if (first == NULL) {
+       if (!first) {
                radlog(L_ERR, "rlm_eap2: EAP-Message not found");
                return -1;
        }
@@ -910,7 +910,7 @@ static rlm_rcode_t mod_authenticate(void *instance, REQUEST *request)
                handler->server_ctx.eap = eap_server_sm_init(handler,
                                                             &handler->eap_cb,
                                                             &handler->eap_conf);
-               if (handler->server_ctx.eap == NULL) {
+               if (!handler->server_ctx.eap) {
                        free(handler);
                        return RLM_MODULE_FAIL;
                }
index 2d0795b..b7eb63f 100644 (file)
@@ -158,11 +158,11 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        }
        cache_size = data->cache_size;
 
-       if (data->session_db == NULL) {
+       if (!data->session_db) {
                radlog(L_ERR, "rlm_ippool: 'session-db' must be set.");
                return -1;
        }
-       if (data->ip_index == NULL) {
+       if (!data->ip_index) {
                radlog(L_ERR, "rlm_ippool: 'ip-index' must be set.");
                return -1;
        }
@@ -177,14 +177,14 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
 
        data->gdbm = gdbm_open(data->session_db, sizeof(int),
                        GDBM_WRCREAT | GDBM_IPPOOL_OPTS, 0600, NULL);
-       if (data->gdbm == NULL) {
+       if (!data->gdbm) {
                radlog(L_ERR, "rlm_ippool: Failed to open file %s: %s",
                                data->session_db, strerror(errno));
                return -1;
        }
        data->ip = gdbm_open(data->ip_index, sizeof(int),
                        GDBM_WRCREAT | GDBM_IPPOOL_OPTS, 0600, NULL);
-       if (data->ip == NULL) {
+       if (!data->ip) {
                radlog(L_ERR, "rlm_ippool: Failed to open file %s: %s",
                                data->ip_index, strerror(errno));
                return -1;
@@ -195,7 +195,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
                radlog(L_ERR, "rlm_ippool: Failed to set cache size");
 
        key_datum = gdbm_firstkey(data->gdbm);
-       if (key_datum.dptr == NULL){
+       if (!key_datum.dptr){
                        /*
                         * If the database does not exist initialize it.
                         * We set the nas/port pairs to not existent values and
@@ -429,7 +429,7 @@ static rlm_rcode_t mod_post_auth(void *instance, REQUEST *request)
         * run only if they match
         */
        if ((vp = pairfind(request->config_items, PW_POOL_NAME, 0, TAG_ANY)) != NULL){
-               if (data->name == NULL || (strcmp(data->name,vp->vp_strvalue) && strcmp(vp->vp_strvalue,"DEFAULT")))
+               if (!data->name || (strcmp(data->name,vp->vp_strvalue) && strcmp(vp->vp_strvalue,"DEFAULT")))
                        return RLM_MODULE_NOOP;
        } else {
                RDEBUG("Could not find Pool-Name attribute.");
@@ -584,7 +584,7 @@ static rlm_rcode_t mod_post_auth(void *instance, REQUEST *request)
                }
        }
 
-       if (key_datum.dptr == NULL){
+       if (!key_datum.dptr){
                key_datum = gdbm_firstkey(data->gdbm);
                while(key_datum.dptr){
                        data_datum = gdbm_fetch(data->gdbm, key_datum);
index f020122..2254ab8 100644 (file)
@@ -134,12 +134,12 @@ void addip(char *sessiondbname, char *indexdbname, char *ipaddress,
                return;
        }
 
-       if (sessiondb == NULL) {
+       if (!sessiondb) {
                printf("rlm_ippool_tool: Unable to open DB '%s'\n", sessiondbname);
                return;
        }
 
-       if (indexdb == NULL) {
+       if (!indexdb) {
                printf("rlm_ippool_tool: Unable to open DB '%s'\n", indexdbname);
                return;
        }
@@ -226,7 +226,7 @@ void addip(char *sessiondbname, char *indexdbname, char *ipaddress,
        }
        key_datum.dptr = NULL;
 
-       if (key_datum.dptr == NULL) {
+       if (!key_datum.dptr) {
                key_datum = gdbm_firstkey(sessiondb);
                
                while (key_datum.dptr) {
@@ -369,7 +369,7 @@ void tonewformat(char *sessiondbname, char *newsessiondbname) {
        sessiondb = gdbm_open(sessiondbname, 512, GDBM_READER, 0,NULL);
        newsessiondb = gdbm_open(newsessiondbname, 512, GDBM_NEWDB, 0,NULL);
 
-       if (sessiondb == NULL || newsessiondb == NULL) return;
+       if (!sessiondb || !newsessiondb) return;
 
        memset(key_str, 0, 17);
 
@@ -403,7 +403,7 @@ void tonewformat(char *sessiondbname, char *newsessiondbname) {
                newkey_datum.dsize = sizeof(ippool_key);
                data_datum = gdbm_fetch(sessiondb, key_datum);
                
-               if (data_datum.dptr == NULL) {
+               if (!data_datum.dptr) {
                        goto next;
                }
                
@@ -442,7 +442,7 @@ void viewdb(char *sessiondbname, char *indexdbname, char *ipaddress, int old) {
        sessiondb = gdbm_open(sessiondbname, 512, mode, 0,NULL);
        indexdb = gdbm_open(indexdbname, 512, mode, 0,NULL);
 
-       if ((sessiondb == NULL) || (indexdb == NULL)) {
+       if ((!sessiondb) || (!indexdb)) {
                return;
        }
        
@@ -464,7 +464,7 @@ void viewdb(char *sessiondbname, char *indexdbname, char *ipaddress, int old) {
                }
        
                data_datum = gdbm_fetch(sessiondb, key_datum);
-               if (data_datum.dptr == NULL) {
+               if (!data_datum.dptr) {
                        goto next;
                }
                
@@ -552,7 +552,7 @@ void viewdb(char *sessiondbname, char *indexdbname, char *ipaddress, int old) {
                
                if (vflag && MATCH_IP(ipaddress, ip) && MATCH_ACTIVE(info)) {
                        printf("\n");
-               } else if (vflag && ipaddress == NULL){
+               } else if (vflag && !ipaddress){
                        if (old) {
                                printf("NAS:%s port:0x%x\n", old_key.nas, old_key.port);
                        } else  {
index 27f046b..8111a61 100644 (file)
@@ -293,7 +293,7 @@ static rlm_rcode_t do_linelog(void *instance, REQUEST *request)
                        gid = strtol(inst->group, &endptr, 10);
                        if (*endptr != '\0') {
                                grp = getgrnam(inst->group);
-                               if (grp == NULL) {
+                               if (!grp) {
                                        RDEBUG2("Unable to find system group \"%s\"", inst->group);
                                        goto skip_group;
                                }
index aa6628f..4bfb4d6 100644 (file)
@@ -70,13 +70,13 @@ static int getUserNodeRef(REQUEST *request, char* inUserName, char **outUserName
        tDataList              *pUserNode       = NULL;
        int                  result             = RLM_MODULE_FAIL;
        
-       if (inUserName == NULL) {
+       if (!inUserName) {
                radlog(L_ERR, "rlm_mschap: getUserNodeRef(): no username");
                return RLM_MODULE_FAIL;
        }
 
        tDataBuff = dsDataBufferAllocate(dsRef, 4096);
-       if (tDataBuff == NULL) {
+       if (!tDataBuff) {
                radlog(L_ERR, "rlm_mschap: getUserNodeRef(): dsDataBufferAllocate() status = %ld", status);
                return RLM_MODULE_FAIL;
        }
@@ -180,7 +180,7 @@ static int getUserNodeRef(REQUEST *request, char* inUserName, char **outUserName
                }
 
                pUserNode = dsBuildFromPath(dsRef, pUserLocation, "/");
-               if (pUserNode == NULL) {
+               if (!pUserNode) {
                        radlog(L_ERR,"rlm_mschap: getUserNodeRef(): dsBuildFromPath() returned NULL");
                        result = RLM_MODULE_FAIL;
                        break;
@@ -246,7 +246,7 @@ int od_mschap_auth(REQUEST *request, VALUE_PAIR *challenge,
 #endif
        
        username_string = talloc_array(request, char, usernamepair->length + 1);
-       if (username_string == NULL)
+       if (!username_string)
                return RLM_MODULE_FAIL;
        
        strlcpy(username_string, (char *)usernamepair->vp_strvalue,
index bdb323c..8714c67 100644 (file)
@@ -92,7 +92,7 @@ static long od_check_passwd(const char *uname, const char *password)
        uint32_t                uiLen           = 0;
        uint32_t                pwLen           = 0;
        
-       if (uname == NULL || password == NULL)
+       if (!uname || !password)
                return result;
        
        do
@@ -102,7 +102,7 @@ static long od_check_passwd(const char *uname, const char *password)
                        return result;
                
                tDataBuff = dsDataBufferAllocate( dsRef, 4096 );
-               if (tDataBuff == NULL)
+               if (!tDataBuff)
                        break;
                
                /* find user on search node */
@@ -379,7 +379,7 @@ static rlm_rcode_t mod_authorize(UNUSED void *instance, REQUEST *request)
                if (uuid_parse(rad_client->community, guid_nasgroup) != 0) {
                        /* attempt to resolve the name */
                        groupdata = getgrnam(rad_client->community);
-                       if (groupdata == NULL) {
+                       if (!groupdata) {
                                radlog(L_AUTH, "rlm_opendirectory: The group \"%s\" does not exist on this system.", rad_client->community);
                                return RLM_MODULE_FAIL;
                        }
@@ -393,7 +393,7 @@ static rlm_rcode_t mod_authorize(UNUSED void *instance, REQUEST *request)
        else
 #endif
        {
-               if (rad_client == NULL) {
+               if (!rad_client) {
                        RDEBUG("The client record could not be found for host %s.",
                                        ip_ntoh(&request->packet->src_ipaddr,
                                                host_ipaddr, sizeof(host_ipaddr)));
index f1f0d77..65a4596 100644 (file)
@@ -717,7 +717,7 @@ static rlm_rcode_t mod_authenticate(void *instance, REQUEST *request)
        /*
         *      No attribute was found that looked like a password to match.
         */
-       if (auth_func == NULL) {
+       if (!auth_func) {
                RDEBUG("No password configured for the user.  Cannot do authentication");
                return RLM_MODULE_FAIL;
        }
index afc9587..7908a12 100644 (file)
@@ -132,7 +132,7 @@ static unsigned int hash(const char * username, unsigned int tablesize)
 static void release_hash_table(struct hashtable * ht){
        int i;
 
-       if (ht == NULL) return;
+       if (!ht) return;
        for (i = 0; i < ht->tablesize; i++)
                if (ht->table[i])
                        destroy_password(ht->table[i]);
@@ -420,7 +420,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        }
 
        lf = talloc_strdup(inst, inst->format);
-       if ( lf == NULL) {
+       if ( !lf) {
                radlog(L_ERR, "rlm_passwd: memory allocation failed for lf");
                return -1;
        }
index 317329e..3c92395 100644 (file)
@@ -502,7 +502,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        PL_endav = end_AV;
 
        xlat_name = cf_section_name2(conf);
-       if (xlat_name == NULL)
+       if (!xlat_name)
                xlat_name = cf_section_name1(conf);
        if (xlat_name) {
                xlat_register(xlat_name, perl_xlat, inst);
@@ -581,7 +581,7 @@ static void perl_store_vps(TALLOC_CTX *ctx, VALUE_PAIR *vps, HV *rad_hv)
                pairfree(&sublist);
        }
 
-       rad_assert(head == NULL);
+       rad_assert(!head);
 }
 
 /*
index 6278ead..ab76125 100644 (file)
@@ -266,7 +266,7 @@ static void rad_mangle(rlm_preprocess_t *data, REQUEST *request)
         */
        request_pairs = request->packet->vps;
        namepair = pairfind(request_pairs, PW_USER_NAME, 0, TAG_ANY);
-       if ((namepair == NULL) ||
+       if ((!namepair) ||
            (namepair->length <= 0)) {
          return;
        }
@@ -345,7 +345,7 @@ static int hunt_paircmp(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check)
        VALUE_PAIR      *tmp;
        int             result = -1;
 
-       if (check == NULL) return 0;
+       if (!check) return 0;
 
        while (result != 0 && check_item != NULL) {
 
@@ -378,7 +378,7 @@ static int hints_setup(PAIR_LIST *hints, REQUEST *request)
 
        request_pairs = request->packet->vps;
 
-       if (hints == NULL || request_pairs == NULL)
+       if (!hints || !request_pairs)
                return RLM_MODULE_NOOP;
 
        /*
@@ -389,7 +389,7 @@ static int hints_setup(PAIR_LIST *hints, REQUEST *request)
        else
                name = (char *)tmp->vp_strvalue;
 
-       if (name == NULL || name[0] == 0)
+       if (!name || name[0] == 0)
                /*
                 *      No name, nothing to do.
                 */
@@ -438,7 +438,7 @@ static int huntgroup_access(REQUEST *request, PAIR_LIST *huntgroups)
         *      We're not controlling access by huntgroups:
         *      Allow them in.
         */
-       if (huntgroups == NULL)
+       if (!huntgroups)
                return RLM_MODULE_OK;
 
        for(i = huntgroups; i; i = i->next) {
index 5095180..b75f1dd 100644 (file)
@@ -178,7 +178,7 @@ static void mod_error(void)
        Pyx_BLOCK_THREADS
 
        PyErr_Fetch(&pType, &pValue, &pTraceback);
-       if (pType == NULL || pValue == NULL)
+       if (!pType || !pValue)
                goto failed;
        if (((pStr1 = PyObject_Str(pType)) == NULL) ||
            ((pStr2 = PyObject_Str(pValue)) == NULL))
@@ -337,7 +337,7 @@ static int mod_populate_vptuple(PyObject *pPair, VALUE_PAIR *vp)
        else
                pStr = PyString_FromString(vp->da->name);
        
-       if (pStr == NULL)
+       if (!pStr)
                goto failed;
        
        PyTuple_SET_ITEM(pPair, 0, pStr);
@@ -366,7 +366,7 @@ static int do_python(REQUEST *request, PyObject *pFunc,
        PyGILState_STATE gstate;
        
        /* Return with "OK, continue" if the function is not defined. */
-       if (pFunc == NULL)
+       if (!pFunc)
                return RLM_MODULE_OK;
        
        /* Default return value is "OK, continue" */
@@ -419,10 +419,10 @@ static int do_python(REQUEST *request, PyObject *pFunc,
        /* Call Python function. */
        pRet = PyObject_CallFunctionObjArgs(pFunc, pArgs, NULL);
        
-       if (pRet == NULL)
+       if (!pRet)
                goto failed;
        
-       if (request == NULL)
+       if (!request)
                goto okay;
 
        /*
index 61bc0bc..d2d703e 100644 (file)
@@ -79,7 +79,7 @@ static int check_for_realm(void *instance, REQUEST *request, REALM **returnrealm
         *      Also, if there's no User-Name attribute, we can't
         *      proxy it, either.
         */
-       if ((request->username == NULL)
+       if ((!request->username)
 #ifdef WITH_PROXY
            || (request->proxy != NULL)
 #endif
@@ -161,7 +161,7 @@ static int check_for_realm(void *instance, REQUEST *request, REALM **returnrealm
        realm = realm_find(realmname);
        if (!realm) {
                RDEBUG2("No such realm \"%s\"",
-                      (realmname == NULL) ? "NULL" : realmname);
+                      (!realmname) ? "NULL" : realmname);
                return RLM_MODULE_NOOP;
        }
        if( inst->ignore_default &&
index 8ee484d..4d9d149 100644 (file)
@@ -178,7 +178,7 @@ static size_t redis_xlat(void *instance, REQUEST *request,
                break;
        }
 
-       if ((ret >= freespace) || (buffer_ptr == NULL)) {
+       if ((ret >= freespace) || (!buffer_ptr)) {
                RDEBUG("rlm_redis (%s): Can't write result, insufficient space or unsupported result\n",
                       inst->xlat_name);
                ret = 0;
index 248aa48..c218f0a 100644 (file)
@@ -1032,7 +1032,7 @@ static int rest_decode_post(rlm_rest_t *instance,
                        "¿Unknown?"));
 
                q = strchr(p, '&');
-               len = (q == NULL) ? (rawlen - (p - raw)) : (unsigned)(q - p);
+               len = (!q) ? (rawlen - (p - raw)) : (unsigned)(q - p);
 
                value = curl_easy_unescape(candle, p, len, &curl_len);
 
@@ -1041,7 +1041,7 @@ static int rest_decode_post(rlm_rest_t *instance,
                 *      if we didn't we do *NOT* want to skip over the end
                 *      of the buffer...
                 */
-               p += (q == NULL) ? len : (len + 1);
+               p += (!q) ? len : (len + 1);
 
                RDEBUG2("\tLength : %i", curl_len);
                RDEBUG2("\tValue  : \"%s\"", value);
@@ -1551,7 +1551,7 @@ static size_t rest_write_header(void *ptr, size_t size, size_t nmemb,
                         * of reason_code.
                         */
                        q = memchr(p, ' ', s);
-                       if (q == NULL) goto malformed;
+                       if (!q) goto malformed;
 
                        s -= (q - p);
                        p  = q;
@@ -1578,7 +1578,7 @@ static size_t rest_write_header(void *ptr, size_t size, size_t nmemb,
                                s -= 4;
 
                                q = memchr(p, '\r', s);
-                               if (q == NULL) goto malformed;
+                               if (!q) goto malformed;
 
                                len = (q - p);
 
@@ -1612,9 +1612,9 @@ static size_t rest_write_header(void *ptr, size_t size, size_t nmemb,
                                 *      If there's not, find the end of this
                                 *      header.
                                 */
-                               if (q == NULL) q = memchr(p, '\r', s);
+                               if (!q) q = memchr(p, '\r', s);
 
-                               len = (q == NULL) ? s : (unsigned)(q - p);
+                               len = (!q) ? s : (unsigned)(q - p);
 
                                type = fr_substr2int(http_content_type_table,
                                        p, HTTP_BODY_UNKNOWN,
@@ -2231,7 +2231,7 @@ int rest_request_decode(rlm_rest_t *instance,
 
        int ret;
 
-       if (ctx->write.buffer == NULL) {
+       if (!ctx->write.buffer) {
                RDEBUG("Skipping attribute processing, no body data received");
                return FALSE;
        }
index eb86f9e..ee9cb86 100644 (file)
@@ -244,7 +244,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        }
 
        xlat_name = cf_section_name2(conf);
-       if (xlat_name == NULL) {
+       if (!xlat_name) {
                xlat_name = cf_section_name1(conf);
        }
 
index f14100c..044388f 100644 (file)
@@ -310,7 +310,7 @@ static struct varlookup {
  * Import a user module and load a function from it
  */
 static int load_function(const char *f_name, int *func, VALUE module) {
-    if (f_name == NULL) {
+    if (!f_name) {
        *func = 0;
     } else {
        *func = rb_intern(f_name);
@@ -385,7 +385,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
     /* Add functions into module */
     rb_define_module_function(module, "radlog", radlog_rb, 2);
 
-    if (data->scriptFile == NULL) {
+    if (!data->scriptFile) {
        /* TODO: What actualy should we do? Exit with module fail? Or continue... but what the point then? */
        radlog(L_ERR, "Script File was not set");
     } else {
index 5e09d50..0b9681d 100644 (file)
@@ -95,7 +95,7 @@ static SECURID_AUTH_RC securidAuth(void *instance, REQUEST *request,
        *replyMsgBuffer = '\0';
 
        pSecurid_session = securid_sessionlist_find(inst,request);
-       if (pSecurid_session == NULL) {
+       if (!pSecurid_session) {
                /* securid session not found */
                SDI_HANDLE  sdiHandle = SDI_HANDLE_NONE;
 
index 49e60db..c61a210 100644 (file)
@@ -145,7 +145,7 @@ static int sql_query(rlm_sql_handle_t *handle, rlm_sql_config_t *config, char *q
 {
        rlm_sql_freetds_conn_t *conn = handle->conn;
        
-       if (conn->dbproc == NULL || DBDEAD(conn->dbproc)) {
+       if (!conn->dbproc || DBDEAD(conn->dbproc)) {
                radlog(L_ERR, "rlm_sql_freetds (%s): Socket not connected", config->xlat_name);
                return SQL_DOWN;
        }
index 389ed70..bb14d59 100644 (file)
@@ -135,7 +135,7 @@ static int sql_query(rlm_sql_handle_t *handle, rlm_sql_config_t *config, char *q
                return -1;
        }
 
-       if (conn->dbc_handle == NULL) {
+       if (!conn->dbc_handle) {
                radlog(L_ERR, "sql_query:  Socket not connected");
                return -1;
        }
index fa09421..f7abff0 100644 (file)
@@ -183,7 +183,7 @@ static int sql_query(rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config,
 {
        rlm_sql_mysql_conn_t *conn = handle->conn;
 
-       if (conn->sock == NULL) {
+       if (!conn->sock) {
                radlog(L_ERR, "rlm_sql_mysql: Socket not connected");
                return SQL_DOWN;
        }
@@ -207,7 +207,7 @@ static int sql_store_result(rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *
        rlm_sql_mysql_conn_t *conn = handle->conn;
        int status;
 
-       if (conn->sock == NULL) {
+       if (!conn->sock) {
                radlog(L_ERR, "rlm_sql_mysql: Socket not connected");
                return SQL_DOWN;
        }
@@ -336,7 +336,7 @@ static int sql_fetch_row(rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *con
 retry_fetch_row:
        handle->row = mysql_fetch_row(conn->result);
 
-       if (handle->row == NULL) {
+       if (!handle->row) {
                status = sql_check_error(mysql_errno(conn->sock));
                if (status != 0) {
                        radlog(L_ERR, "rlm_sql_mysql: Cannot fetch row");
@@ -398,7 +398,7 @@ static const char *sql_error(rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t
 {
        rlm_sql_mysql_conn_t *conn = handle->conn;
 
-       if (conn == NULL || conn->sock == NULL) {
+       if (!conn || !conn->sock) {
                return "rlm_sql_mysql: no connection to db";
        }
        return mysql_error(conn->sock);
index 2ebd55b..568fc5c 100644 (file)
@@ -213,7 +213,7 @@ static int sql_query(rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config,
        char *errorcode;
        char *errormsg;
 
-       if (conn->db == NULL) {
+       if (!conn->db) {
                radlog(L_ERR, "rlm_sql_postgresql: Socket not connected");
                return SQL_DOWN;
        }
index 5d81f6f..55d79c4 100644 (file)
@@ -383,7 +383,7 @@ static int sql_query(rlm_sql_handle_t *handle, rlm_sql_config_t *config, char *q
        CS_RETCODE      ret, results_ret;
        CS_INT          result_type;
 
-        if (conn->db == NULL) {
+        if (!conn->db) {
                radlog(L_ERR, "Socket not connected");
                return -1;
        }
@@ -592,7 +592,7 @@ static int sql_select_query(rlm_sql_handle_t *handle, rlm_sql_config_t *config,
        int             colcount,i;
        char            **rowdata;
 
-        if (conn->db == NULL) {
+        if (!conn->db) {
                radlog(L_ERR, "Socket not connected");
                return -1;
        }
index d94e584..9568b39 100644 (file)
@@ -154,7 +154,7 @@ static size_t sql_xlat(void *instance, REQUEST *request,
        }
 
        handle = sql_get_socket(inst);
-       if (handle == NULL)
+       if (!handle)
                return 0;
 
        rlm_sql_query_log(inst, request, NULL, querystr);
@@ -222,14 +222,14 @@ static size_t sql_xlat(void *instance, REQUEST *request,
        }
 
        row = handle->row;
-       if (row == NULL) {
+       if (!row) {
                RDEBUG("SQL query did not return any results");
                (inst->module->sql_finish_select_query)(handle, inst->config);
                sql_release_socket(inst,handle);
                return 0;
        }
 
-       if (row[0] == NULL){
+       if (!row[0]){
                RDEBUG("Null value in first column");
                (inst->module->sql_finish_select_query)(handle, inst->config);
                sql_release_socket(inst,handle);
@@ -271,7 +271,7 @@ static int generate_sql_clients(rlm_sql_t *inst)
              inst->config->xlat_name, querystr);
 
        handle = sql_get_socket(inst);
-       if (handle == NULL)
+       if (!handle)
                return -1;
        if (rlm_sql_select_query(&handle,inst,querystr)){
                return -1;
@@ -280,7 +280,7 @@ static int generate_sql_clients(rlm_sql_t *inst)
        while(rlm_sql_fetch_row(&handle, inst) == 0) {
                i++;
                row = handle->row;
-               if (row == NULL)
+               if (!row)
                        break;
                /*
                 *  The return data for each row MUST be in the following order:
@@ -510,9 +510,9 @@ static int sql_get_grouplist(rlm_sql_t *inst, rlm_sql_handle_t *handle,
        }
        while (rlm_sql_fetch_row(&handle, inst) == 0) {
                row = handle->row;
-               if (row == NULL)
+               if (!row)
                        break;
-               if (row[0] == NULL){
+               if (!row[0]){
                        RDEBUG("row[0] returned NULL");
                        (inst->module->sql_finish_select_query)(handle, inst->config);
                        talloc_free(entry);
@@ -573,7 +573,7 @@ static int sql_groupcmp(void *instance, REQUEST *request, VALUE_PAIR *request_vp
         *      Get a socket for this lookup
         */
        handle = sql_get_socket(inst);
-       if (handle == NULL) {
+       if (!handle) {
                return 1;
        }
 
@@ -828,7 +828,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
        inst->cs = conf;
 
        xlat_name = cf_section_name2(conf);
-       if (xlat_name == NULL) {
+       if (!xlat_name) {
                xlat_name = cf_section_name1(conf);
        } else {
                char *group_name;
@@ -902,7 +902,7 @@ static int mod_instantiate(CONF_SECTION *conf, void **instance)
         *      Load the appropriate driver for our database
         */
        inst->handle = lt_dlopenext(inst->config->sql_driver_name);
-       if (inst->handle == NULL) {
+       if (!inst->handle) {
                radlog(L_ERR, "Could not link driver %s: %s",
                       inst->config->sql_driver_name,
                       dlerror());
@@ -1004,7 +1004,7 @@ static rlm_rcode_t mod_authorize(void *instance, REQUEST * request)
         *  temporary pairlists and temporary attributes.
         */
        handle = sql_get_socket(inst);
-       if (handle == NULL)
+       if (!handle)
                goto error;
 
        /*
@@ -1206,7 +1206,7 @@ static int acct_redundant(rlm_sql_t *inst, REQUEST *request,
        RDEBUG2("Using query template '%s'", attr);
        
        handle = sql_get_socket(inst);
-       if (handle == NULL)
+       if (!handle)
                return RLM_MODULE_FAIL;
                
        sql_set_user(inst, request, NULL);
@@ -1332,7 +1332,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST * request) {
                return RLM_MODULE_NOOP;
        }
 
-       if((request->username == NULL) || (request->username->length == 0)) {
+       if((!request->username) || (request->username->length == 0)) {
                radlog_request(L_ERR, 0, request,
                                           "Zero Length username not permitted\n");
                return RLM_MODULE_INVALID;
@@ -1346,7 +1346,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST * request) {
 
        /* initialize the sql socket */
        handle = sql_get_socket(inst);
-       if(handle == NULL)
+       if(!handle)
                return RLM_MODULE_FAIL;
 
        if(rlm_sql_select_query(&handle, inst, querystr)) {
@@ -1362,7 +1362,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST * request) {
        }
 
        row = handle->row;
-       if (row == NULL) {
+       if (!row) {
                (inst->module->sql_finish_select_query)(handle, inst->config);
                sql_release_socket(inst, handle);
                return RLM_MODULE_FAIL;
@@ -1405,7 +1405,7 @@ static rlm_rcode_t mod_checksimul(void *instance, REQUEST * request) {
 
        while (rlm_sql_fetch_row(&handle, inst) == 0) {
                row = handle->row;
-               if (row == NULL)
+               if (!row)
                        break;
                if (!row[2]){
                        (inst->module->sql_finish_select_query)(handle, inst->config);
index a66d383..8cafe2d 100644 (file)
@@ -173,7 +173,7 @@ int sql_userparse(TALLOC_CTX *ctx, VALUE_PAIR **head, rlm_sql_row_t row)
        /*
         *      Verify the 'Attribute' field
         */
-       if (row[2] == NULL || row[2][0] == '\0') {
+       if (!row[2] || row[2][0] == '\0') {
                radlog(L_ERR, "rlm_sql: The 'Attribute' field is empty or NULL, skipping the entire row.");
                return -1;
        }
index 359bcd8..a5c86ab 100644 (file)
@@ -94,11 +94,11 @@ static int groupcmp(void *instance, REQUEST *req, UNUSED VALUE_PAIR *request,
        }
 
        pwd = getpwnam(req->username->vp_strvalue);
-       if (pwd == NULL)
+       if (!pwd)
                return -1;
 
        grp = getgrnam(check->vp_strvalue);
-       if (grp == NULL)
+       if (!grp)
                return -1;
        
        retval = (pwd->pw_gid == grp->gr_gid) ? 0 : -1;
@@ -219,7 +219,7 @@ static rlm_rcode_t mod_authorize(UNUSED void *instance, REQUEST *request)
         *      prevents users from using NULL password fields as things
         *      stand right now.
         */
-       if ((encrypted_pass == NULL) || (strlen(encrypted_pass) < 10)) {
+       if ((!encrypted_pass) || (strlen(encrypted_pass) < 10)) {
                if ((spwd = getspnam(name)) == NULL) {
                        return RLM_MODULE_NOTFOUND;
                }
@@ -254,7 +254,7 @@ static rlm_rcode_t mod_authorize(UNUSED void *instance, REQUEST *request)
                }
        }
        endusershell();
-       if (shell == NULL) {
+       if (!shell) {
                radlog_request(L_AUTH, 0, request, "[%s]: invalid shell [%s]",
                       name, pwd->pw_shell);
                return RLM_MODULE_REJECT;