fixup DIAG_{ON,OFF} to get rid of compiler errors
authorMatthew Newton <mcn4@leicester.ac.uk>
Fri, 19 Apr 2013 23:44:37 +0000 (00:44 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 20 Apr 2013 00:00:37 +0000 (20:00 -0400)
about not using #pragmas inside functions

src/main/log.c
src/main/radattr.c
src/main/valuepair.c
src/modules/rlm_ldap/ldap.c
src/modules/rlm_perl/rlm_perl.c
src/modules/rlm_sqlhpwippool/rlm_sqlhpwippool.c

index 0e6a499..2532dd9 100644 (file)
@@ -78,6 +78,7 @@ int log_dates_utc = 0;
  *     Log the message to the logfile. Include the severity and
  *     a time stamp.
  */
+DIAG_OFF(format-nonliteral)
 int vradlog(int lvl, char const *fmt, va_list ap)
 {
        struct main_config_t *myconfig = &mainconfig;
@@ -153,9 +154,7 @@ int vradlog(int lvl, char const *fmt, va_list ap)
        }
 
        if (len < sizeof(buffer)) {
-DIAG_OFF(format-nonliteral)
                len += vsnprintf(buffer + len, sizeof(buffer) - len - 1, fmt, ap);
-DIAG_ON(format-nonliteral)
        }
        
        /*
@@ -223,6 +222,7 @@ DIAG_ON(format-nonliteral)
 
        return 0;
 }
+DIAG_ON(format-nonliteral)
 
 int log_debug(char const *msg, ...)
 {
index 4fae513..41abe20 100644 (file)
@@ -59,31 +59,31 @@ int radius_get_vp(UNUSED REQUEST *request, UNUSED char const *name, UNUSED VALUE
        return 0;
 }
 
+DIAG_OFF(format-nonliteral)
 void radlog_request(UNUSED int lvl, UNUSED int priority, UNUSED REQUEST *request, char const *msg, ...)
 {
        va_list ap;
        char buffer[256];
 
-DIAG_OFF(format-nonliteral)
        va_start(ap, msg);
        vsnprintf(buffer, sizeof(buffer), msg, ap);
-DIAG_ON(format-nonliteral)
        va_end(ap);
 }
+DIAG_ON(format-nonliteral)
 
+DIAG_OFF(format-nonliteral)
 int radlog(UNUSED int lvl, char const *msg, ...)
 {
        va_list ap;
        char buffer[256];
 
        va_start(ap, msg);
-DIAG_OFF(format-nonliteral)
        vsnprintf(buffer, sizeof(buffer), msg, ap);
-DIAG_ON(format-nonliteral)
        va_end(ap);
 
        return 0;
 }
+DIAG_ON(format-nonliteral)
 
 static size_t xlat_test(UNUSED void *instance, UNUSED REQUEST *request,
                       UNUSED char const *fmt, UNUSED char *out, UNUSED size_t outlen)
index 3169452..ed6a443 100644 (file)
@@ -1645,6 +1645,7 @@ int radius_get_vp(REQUEST *request, char const *name, VALUE_PAIR **vp_p)
 
 /** Add a module failure message VALUE_PAIR to the request
  */
+DIAG_OFF(format-nonliteral)
 void module_failure_msg(REQUEST *request, char const *fmt, ...)
 {
        size_t len;
@@ -1660,8 +1661,7 @@ void module_failure_msg(REQUEST *request, char const *fmt, ...)
 
        len = snprintf(vp->vp_strvalue, sizeof(vp->vp_strvalue), "%s: ", request->module);
        
-DIAG_OFF(format-nonliteral)
        vsnprintf(vp->vp_strvalue + len, sizeof(vp->vp_strvalue) - len, fmt, ap);
-DIAG_ON(format-nonliteral)
        pairadd(&request->packet->vps, vp);
 }
+DIAG_ON(format-nonliteral)
index 376ba34..b38cf86 100644 (file)
@@ -1012,6 +1012,8 @@ static int rlm_ldap_rebind(LDAP *handle, LDAP_CONST char *url, UNUSED ber_tag_t
  * @param instance rlm_ldap instance.
  * @return A new connection handle or NULL on error.
  */
+DIAG_OFF(implicit-function-declaration)
+DIAG_OFF(nested-externs)
 void *mod_conn_create(void *instance)
 {
        ldap_rcode_t status;
@@ -1116,11 +1118,7 @@ void *mod_conn_create(void *instance)
        maybe_ldap_option(LDAP_OPT_X_TLS_CACERTDIR, "cacertdir", inst->tls_cacertdir);
 
 #  ifdef HAVE_LDAP_INT_TLS_CONFIG
-DIAG_OFF(implicit-function-declaration)
-DIAG_OFF(nested-externs)
        if (ldap_int_tls_config(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, inst->tls_require_cert) != LDAP_OPT_SUCCESS) {
-DIAG_ON(nested-externs)
-DIAG_ON(implicit-function-declaration)
                ldap_get_option(handle, LDAP_OPT_ERROR_NUMBER, &ldap_errno);
                
                LDAP_ERR("Could not set LDAP_OPT_X_TLS_REQUIRE_CERT option to %s: %s", inst->tls_require_cert,
@@ -1175,6 +1173,8 @@ DIAG_ON(implicit-function-declaration)
        
        return NULL;
 }
+DIAG_ON(nested-externs)
+DIAG_ON(implicit-function-declaration)
 
 
 /** Close and delete a connection
index d4a7054..e1598cf 100644 (file)
@@ -187,9 +187,9 @@ static void rlm_perl_close_handles(void **handles)
        free(handles);
 }
 
+DIAG_OFF(shadow)
 static void rlm_perl_destruct(PerlInterpreter *perl)
 {
-DIAG_OFF(shadow)
        dTHXa(perl);
 
        PERL_SET_CONTEXT(perl);
@@ -202,7 +202,6 @@ DIAG_OFF(shadow)
        {
                dTHXa(perl);
        }
-DIAG_ON(shadow)
        /*
         * FIXME: This shouldn't happen
         *
@@ -214,6 +213,7 @@ DIAG_ON(shadow)
        perl_destruct(perl);
        perl_free(perl);
 }
+DIAG_ON(shadow)
 
 static void rlm_destroy_perl(PerlInterpreter *perl)
 {
index 2859efe..5f13d23 100644 (file)
@@ -102,13 +102,12 @@ static int nvp_log(unsigned int line, rlm_sqlhpwippool_t *data, int lvl,
        return r;
 }
 /* handy SQL query tool */
+DIAG_OFF(format-nonliteral)
 static int nvp_vquery(unsigned int line, rlm_sqlhpwippool_t *data,
                      rlm_sql_handle_t *sqlsock, char const *fmt, va_list ap)
 {
        char query[MAX_QUERY_LEN];
-DIAG_OFF(format-nonliteral)
        vsnprintf(query, MAX_QUERY_LEN, fmt, ap);
-DIAG_ON(format-nonliteral)
        if (rlm_sql_query(&sqlsock, data->sqlinst, query)) {
                nvp_log(__LINE__, data, L_ERR, "nvp_vquery(): query from line %u: %s",
                        line, (char const *)(data->db->sql_error)(sqlsock, data->sqlinst->config));
@@ -117,6 +116,7 @@ DIAG_ON(format-nonliteral)
 
        return 1;
 }
+DIAG_ON(format-nonliteral)
 
 /* wrapper around nvp_vquery */
 static int nvp_query(unsigned int line, rlm_sqlhpwippool_t *data,