#26 Fixes for covscan reports
Merged 5 years ago by abbra. Opened 5 years ago by abbra.
abbra/slapi-nis covscan-fixes  into  master

file modified
+6
@@ -55,6 +55,12 @@ 

  #include "map.h"

  #include "back-sch.h"

  

+ /*

+  * This is not a public function in 389-ds but we need to use it in backend_search_cb(),

+  * see a comment there on the difference between slapi_send_ldap_result() and send_ldap_result().

+  */

+ extern void send_ldap_result(Slapi_PBlock *pb, int err, char *matched, char *text, int nentries, struct berval **urls);

+ 

  static int backend_passwdmod_extop(Slapi_PBlock *pb);

  backend_extop_handlers_t extop_handlers[] = {{EXTOP_PASSWD_OID, (IFP) backend_passwdmod_extop},

  					    {NULL, NULL}};

file modified
+3 -1
@@ -37,7 +37,9 @@ 

  #endif

  

  #include <rpc/xdr.h>

- #include <nspr4/prtypes.h>

+ #include <prtypes.h>

+ /* NSPR private API for thread-local variables */

+ #include <private/prpriv.h>

  #include "../yp/yp.h"

  

  #ifdef HAVE_TCPD_H

file modified
+5
@@ -68,6 +68,11 @@ 

  int backend_init_internal_postop(struct slapi_pblock *pb,

  				 struct plugin_state *state);

  

+ /* Only used for schema compatibility plugin*/

+ int backend_init_be_preop(Slapi_PBlock *pb, struct plugin_state *state);

+ int backend_init_be_postop(Slapi_PBlock *pb, struct plugin_state *state);

+ 

+ 

  /* Read the server's name. */

  int backend_read_master_name(struct plugin_state *state,

  			     struct slapi_pblock *pb,

file modified
+16 -12
@@ -23,6 +23,7 @@ 

  #include "config.h"

  #endif

  

+ #include <inttypes.h>

  #include <sys/types.h>

  #include <search.h>

  #include <stdlib.h>
@@ -40,6 +41,9 @@ 

  

  #include <rpc/rpc.h>

  

+ /* NSPR private API for thread-local variables */

+ #include <private/prpriv.h>

+ 

  #include "backend.h"

  #include "disp-nis.h"

  #include "map.h"
@@ -1264,7 +1268,7 @@ 

  

  #if DEBUG_MAP_LOCK

  	slapi_log_error(SLAPI_LOG_FATAL, "map_rdlock",

- 				"thread_id = %p (call level = %d)\n", (void *) PR_MyThreadId(), wrap_get_call_level());

+ 				"thread_id = %"PRIx32" (call level = %d)\n", PR_MyThreadId(), wrap_get_call_level());

  #endif

  	if (lock_status == MAP_RWLOCK_UNINIT) {

  		/* This is not initialized used the old way */
@@ -1284,7 +1288,7 @@ 

  #if DEBUG_MAP_LOCK

          if (lock_count != 0) {

              slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",

-                     "map rdlock: (%p) ALERT !!!   count was %d -> 1\n", (void *) PR_MyThreadId(), lock_count);

+                     "map rdlock: (%"PRIx32") ALERT !!!   count was %d -> 1\n", PR_MyThreadId(), lock_count);

          }

  #endif

  
@@ -1292,12 +1296,12 @@ 

          rc = plugin_rdlock();

          if (rc) {

              slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",

-                     "map rdlock: (%p) MAP_RWLOCK_FREE -> MAP_RLOCK_HELD: fail to read lock plugin lock (%d)\n", (void *) PR_MyThreadId(), rc);

+                     "map rdlock: (%"PRIx32") MAP_RWLOCK_FREE -> MAP_RLOCK_HELD: fail to read lock plugin lock (%d)\n", PR_MyThreadId(), rc);

              return rc;

          }

  #if DEBUG_MAP_LOCK

          slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",

-                 "map rdlock: (%p) MAP_RWLOCK_FREE -> MAP_RLOCK_HELD  : count=%d\n", (void *) PR_MyThreadId(), 1);

+                 "map rdlock: (%"PRIx32") MAP_RWLOCK_FREE -> MAP_RLOCK_HELD  : count=%d\n", PR_MyThreadId(), 1);

  #endif

          rc = wrap_rwlock_rdlock(map_data.lock);

          if (rc) {
@@ -1311,8 +1315,8 @@ 

  

  #if DEBUG_MAP_LOCK

      slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",

-             "map rdlock: (%p) was already hold %s : count=%d > %d!!!\n",

-             (void *) PR_MyThreadId(),

+             "map rdlock: (%x"PRIx32") was already hold %s : count=%d > %d!!!\n",

+             PR_MyThreadId(),

              (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : "MAP_RLOCK_HELD",

              lock_count, lock_count + 1);

  #endif
@@ -1360,25 +1364,25 @@ 

  #if DEBUG_MAP_LOCK

          if (lock_count != 0) {

              slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",

-                     "map wrlock: (%p) ALERT !!!   count was %d --> 1\n", (void *) PR_MyThreadId(), lock_count);

+                     "map wrlock: (%"PRIx32") ALERT !!!   count was %d --> 1\n", PR_MyThreadId(), lock_count);

          }

  #endif

          /* Acquire the slapi plugin in write */

          rc = plugin_wrlock();

          if (rc) {

              slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",

-                     "map wrlock: (%p) MAP_RWLOCK_FREE -> MAP_RLOCK_HELD: fail to read lock plugin lock (%d)\n", (void *) PR_MyThreadId(), rc);

+                     "map wrlock: (%"PRIx32") MAP_RWLOCK_FREE -> MAP_RLOCK_HELD: fail to read lock plugin lock (%d)\n", PR_MyThreadId(), rc);

              return rc;

          }

  #if DEBUG_MAP_LOCK

          slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",

-                 "map wrlock: (%p) MAP_RWLOCK_FREE --> MAP_WLOCK_HELD  : count=%d\n", (void *) PR_MyThreadId(), 1);

+                 "map wrlock: (%"PRIx32") MAP_RWLOCK_FREE --> MAP_WLOCK_HELD  : count=%d\n", PR_MyThreadId(), 1);

  #endif

  

          rc = wrap_rwlock_wrlock(map_data.lock);

          if (rc) {

              slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",

-                     "map wrlock: (%p) MAP_RWLOCK_FREE --> MAP_WLOCK_HELD : fail to write lock map lock (%d)\n", (void *) PR_MyThreadId(), rc);

+                     "map wrlock: (%"PRIx32") MAP_RWLOCK_FREE --> MAP_WLOCK_HELD : fail to write lock map lock (%d)\n", PR_MyThreadId(), rc);

              plugin_unlock();

              goto common;

          }
@@ -1386,8 +1390,8 @@ 

          set_plugin_monitor_count(lock_count + 1);

  #if DEBUG_MAP_LOCK

          slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",

-                 "map wrlock: (%p)  %s --> MAP_WLOCK_HELD  : count=%d\n",

-                 (void *) PR_MyThreadId(),

+                 "map wrlock: (%"PRIx32")  %s --> MAP_WLOCK_HELD  : count=%d\n",

+                 PR_MyThreadId(),

                  (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : "MAP_RLOCK_HELD",

                  lock_count + 1);

  #endif

file modified
+4 -2
@@ -34,6 +34,8 @@ 

  #include <rpc/rpc.h>

  #include "../../yp/yp.h"

  

+ typedef int (*xdrrec_proc_t)(void *, void *, int);

+ 

  static struct sockaddr_in server;

  static int connected;

  
@@ -189,7 +191,7 @@ 

  	}

  

  	memset(&s, 0, sizeof(s));

- 	xdrrec_create(&s, 0, 0, (char *) &sock, &readjunk, &writejunk);

+ 	xdrrec_create(&s, 0, 0, (char *) &sock, (xdrrec_proc_t) &readjunk, (xdrrec_proc_t) &writejunk);

  	s.x_op = XDR_ENCODE;

  

  	memset(&req, 0, sizeof(req));
@@ -218,7 +220,7 @@ 

  	xdr_destroy(&s);

  

  	memset(&s, 0, sizeof(s));

- 	xdrrec_create(&s, 0, 0, (char *) &sock, &readjunk, &writejunk);

+ 	xdrrec_create(&s, 0, 0, (char *) &sock, (xdrrec_proc_t) &readjunk, (xdrrec_proc_t) &writejunk);

  	s.x_op = XDR_DECODE;

  	xdrrec_skiprecord(&s);