svn commit: r194605 - in stable/7/usr.sbin/nscd: . agents

Dag-Erling Smorgrav des at FreeBSD.org
Sun Jun 21 19:50:08 UTC 2009


Author: des
Date: Sun Jun 21 19:50:06 2009
New Revision: 194605
URL: http://svn.freebsd.org/changeset/base/194605

Log:
  merge r194086, r194087, r194089, r194091, r194093, r194094, r194095,
  r194096, r194097, r194098: fix aliasing and other bugs revealed by WARNS,
  major code cleanup

Modified:
  stable/7/usr.sbin/nscd/   (props changed)
  stable/7/usr.sbin/nscd/Makefile
  stable/7/usr.sbin/nscd/agent.c
  stable/7/usr.sbin/nscd/agent.h
  stable/7/usr.sbin/nscd/agents/group.c
  stable/7/usr.sbin/nscd/agents/group.h
  stable/7/usr.sbin/nscd/agents/passwd.c
  stable/7/usr.sbin/nscd/agents/passwd.h
  stable/7/usr.sbin/nscd/agents/services.c
  stable/7/usr.sbin/nscd/agents/services.h
  stable/7/usr.sbin/nscd/cachelib.c
  stable/7/usr.sbin/nscd/cachelib.h
  stable/7/usr.sbin/nscd/cacheplcs.c
  stable/7/usr.sbin/nscd/cacheplcs.h
  stable/7/usr.sbin/nscd/config.c
  stable/7/usr.sbin/nscd/config.h
  stable/7/usr.sbin/nscd/debug.c
  stable/7/usr.sbin/nscd/debug.h
  stable/7/usr.sbin/nscd/hashtable.h
  stable/7/usr.sbin/nscd/log.c
  stable/7/usr.sbin/nscd/mp_rs_query.c
  stable/7/usr.sbin/nscd/mp_ws_query.c
  stable/7/usr.sbin/nscd/nscd.c
  stable/7/usr.sbin/nscd/nscdcli.c
  stable/7/usr.sbin/nscd/parser.c
  stable/7/usr.sbin/nscd/protocol.c
  stable/7/usr.sbin/nscd/protocol.h
  stable/7/usr.sbin/nscd/query.c
  stable/7/usr.sbin/nscd/query.h
  stable/7/usr.sbin/nscd/singletons.c

Modified: stable/7/usr.sbin/nscd/Makefile
==============================================================================
--- stable/7/usr.sbin/nscd/Makefile	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/Makefile	Sun Jun 21 19:50:06 2009	(r194605)
@@ -3,7 +3,7 @@
 PROG=	nscd
 MAN=	nscd.conf.5 nscd.8
 
-WARNS?=	2
+WARNS?=	3
 SRCS=	agent.c nscd.c nscdcli.c cachelib.c cacheplcs.c debug.c log.c \
 	config.c query.c mp_ws_query.c mp_rs_query.c singletons.c protocol.c \
 	parser.c

Modified: stable/7/usr.sbin/nscd/agent.c
==============================================================================
--- stable/7/usr.sbin/nscd/agent.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/agent.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -29,8 +29,9 @@
 __FBSDID("$FreeBSD$");
 
 #include <assert.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
+
 #include "agent.h"
 #include "debug.h"
 
@@ -55,7 +56,7 @@ agent_cmp_func(const void *a1, const voi
 }
 
 struct agent_table *
-init_agent_table()
+init_agent_table(void)
 {
    	struct agent_table	*retval;
 

Modified: stable/7/usr.sbin/nscd/agent.h
==============================================================================
--- stable/7/usr.sbin/nscd/agent.h	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/agent.h	Sun Jun 21 19:50:06 2009	(r194605)
@@ -53,7 +53,7 @@ struct common_agent {
 
 struct multipart_agent {
     	struct agent	parent;
-	void *(*mp_init_func)();
+	void *(*mp_init_func)(void);
     	int (*mp_lookup_func)(char **, size_t *, void *);
 	void (*mp_destroy_func)(void *);
 };
@@ -63,7 +63,7 @@ struct agent_table {
 	size_t		agents_num;
 };
 
-extern struct agent_table *init_agent_table();
+extern struct agent_table *init_agent_table(void);
 extern void register_agent(struct agent_table *, struct agent *);
 extern struct agent *find_agent(struct agent_table *, const char *,
 	enum agent_type);

Modified: stable/7/usr.sbin/nscd/agents/group.c
==============================================================================
--- stable/7/usr.sbin/nscd/agents/group.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/agents/group.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -29,18 +29,19 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
-#include <sys/types.h>
+
 #include <assert.h>
-#include <nsswitch.h>
 #include <grp.h>
-#include <string.h>
+#include <nsswitch.h>
 #include <stdlib.h>
+#include <string.h>
+
 #include "../debug.h"
-#include "passwd.h"
+#include "group.h"
 
 static int group_marshal_func(struct group *, char *, size_t *);
 static int group_lookup_func(const char *, size_t, char **, size_t *);
-static void *group_mp_init_func();
+static void *group_mp_init_func(void);
 static int group_mp_lookup_func(char **, size_t *, void *);
 static void group_mp_destroy_func(void *);
 
@@ -184,7 +185,7 @@ group_lookup_func(const char *key, size_
 }
 
 static void *
-group_mp_init_func()
+group_mp_init_func(void)
 {
 	TRACE_IN(group_mp_init_func);
 	setgrent();
@@ -219,7 +220,7 @@ group_mp_destroy_func(void *mdata)
 }
 
 struct agent *
-init_group_agent()
+init_group_agent(void)
 {
 	struct common_agent	*retval;
 
@@ -238,7 +239,7 @@ init_group_agent()
 }
 
 struct agent *
-init_group_mp_agent()
+init_group_mp_agent(void)
 {
 	struct multipart_agent	*retval;
 

Modified: stable/7/usr.sbin/nscd/agents/group.h
==============================================================================
--- stable/7/usr.sbin/nscd/agents/group.h	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/agents/group.h	Sun Jun 21 19:50:06 2009	(r194605)
@@ -28,5 +28,5 @@
 
 #include "../agent.h"
 
-extern struct agent *init_group_agent();
-extern struct agent *init_group_mp_agent();
+extern struct agent *init_group_agent(void);
+extern struct agent *init_group_mp_agent(void);

Modified: stable/7/usr.sbin/nscd/agents/passwd.c
==============================================================================
--- stable/7/usr.sbin/nscd/agents/passwd.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/agents/passwd.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -29,17 +29,19 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
+
 #include <assert.h>
 #include <nsswitch.h>
 #include <pwd.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
+
 #include "../debug.h"
 #include "passwd.h"
 
 static int passwd_marshal_func(struct passwd *, char *, size_t *);
 static int passwd_lookup_func(const char *, size_t, char **, size_t *);
-static void *passwd_mp_init_func();
+static void *passwd_mp_init_func(void);
 static int passwd_mp_lookup_func(char **, size_t *, void *);
 static void passwd_mp_destroy_func(void *mdata);
 
@@ -191,7 +193,7 @@ passwd_lookup_func(const char *key, size
 }
 
 static void *
-passwd_mp_init_func()
+passwd_mp_init_func(void)
 {
 	TRACE_IN(passwd_mp_init_func);
 	setpwent();
@@ -226,7 +228,7 @@ passwd_mp_destroy_func(void *mdata)
 }
 
 struct agent *
-init_passwd_agent()
+init_passwd_agent(void)
 {
 	struct common_agent	*retval;
 
@@ -245,7 +247,7 @@ init_passwd_agent()
 }
 
 struct agent *
-init_passwd_mp_agent()
+init_passwd_mp_agent(void)
 {
 	struct multipart_agent	*retval;
 

Modified: stable/7/usr.sbin/nscd/agents/passwd.h
==============================================================================
--- stable/7/usr.sbin/nscd/agents/passwd.h	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/agents/passwd.h	Sun Jun 21 19:50:06 2009	(r194605)
@@ -28,5 +28,5 @@
 
 #include "../agent.h"
 
-extern struct agent *init_passwd_agent();
-extern struct agent *init_passwd_mp_agent();
+extern struct agent *init_passwd_agent(void);
+extern struct agent *init_passwd_mp_agent(void);

Modified: stable/7/usr.sbin/nscd/agents/services.c
==============================================================================
--- stable/7/usr.sbin/nscd/agents/services.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/agents/services.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -29,18 +29,19 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
-#include <sys/types.h>
+
 #include <assert.h>
-#include <nsswitch.h>
 #include <netdb.h>
-#include <string.h>
+#include <nsswitch.h>
 #include <stdlib.h>
+#include <string.h>
+
 #include "../debug.h"
 #include "services.h"
 
 static int services_marshal_func(struct servent *, char *, size_t *);
 static int services_lookup_func(const char *, size_t, char **, size_t *);
-static void *services_mp_init_func();
+static void *services_mp_init_func(void);
 static int services_mp_lookup_func(char **, size_t *, void *);
 static void services_mp_destroy_func(void *);
 
@@ -205,7 +206,7 @@ services_lookup_func(const char *key, si
 }
 
 static void *
-services_mp_init_func()
+services_mp_init_func(void)
 {
 	TRACE_IN(services_mp_init_func);
 	setservent(0);
@@ -240,7 +241,7 @@ services_mp_destroy_func(void *mdata)
 }
 
 struct agent *
-init_services_agent()
+init_services_agent(void)
 {
 	struct common_agent	*retval;
 	TRACE_IN(init_services_agent);
@@ -259,7 +260,7 @@ init_services_agent()
 }
 
 struct agent *
-init_services_mp_agent()
+init_services_mp_agent(void)
 {
 	struct multipart_agent	*retval;
 

Modified: stable/7/usr.sbin/nscd/agents/services.h
==============================================================================
--- stable/7/usr.sbin/nscd/agents/services.h	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/agents/services.h	Sun Jun 21 19:50:06 2009	(r194605)
@@ -28,5 +28,5 @@
 
 #include "../agent.h"
 
-extern struct agent *init_services_agent();
-extern struct agent *init_services_mp_agent();
+extern struct agent *init_services_agent(void);
+extern struct agent *init_services_mp_agent(void);

Modified: stable/7/usr.sbin/nscd/cachelib.c
==============================================================================
--- stable/7/usr.sbin/nscd/cachelib.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/cachelib.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -29,9 +29,11 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/time.h>
+
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+
 #include "cachelib.h"
 #include "debug.h"
 
@@ -144,6 +146,7 @@ ht_item_hash_func(const void *p, size_t 
 	return retval;
 }
 
+HASHTABLE_PROTOTYPE(cache_ht_, cache_ht_item_, struct cache_ht_item_data_);
 HASHTABLE_GENERATE(cache_ht_, cache_ht_item_, struct cache_ht_item_data_, data,
 	ht_item_hash_func, ht_items_cmp_func);
 
@@ -289,7 +292,7 @@ clear_cache_entry(struct cache_entry_ *e
 	struct cache_policy_ *policy;
 	struct cache_policy_item_ *item, *next_item;
 	size_t entry_size;
-	int i;
+	unsigned int i;
 
 	if (entry->params->entry_type == CET_COMMON) {
 		common_entry = (struct cache_common_entry_ *)entry;
@@ -394,7 +397,6 @@ flush_cache_policy(struct cache_common_e
 
 		hash = HASHTABLE_CALCULATE_HASH(cache_ht_, &entry->items,
 			&ht_key);
-		assert(hash >= 0);
 		assert(hash < HASHTABLE_ENTRIES_COUNT(&entry->items));
 
 		ht_item = HASHTABLE_GET_ENTRY(&(entry->items), hash);
@@ -563,13 +565,13 @@ register_cache_entry(struct cache_ *the_
 		new_common_entry->params =
 		  (struct cache_entry_params *)&new_common_entry->common_params;
 
-		new_common_entry->common_params.entry_name = (char *)calloc(1,
+		new_common_entry->common_params.cep.entry_name = (char *)calloc(1,
 			entry_name_size);
-		assert(new_common_entry->common_params.entry_name != NULL);
-		strlcpy(new_common_entry->common_params.entry_name,
+		assert(new_common_entry->common_params.cep.entry_name != NULL);
+		strlcpy(new_common_entry->common_params.cep.entry_name,
 			params->entry_name, entry_name_size);
 		new_common_entry->name =
-			new_common_entry->common_params.entry_name;
+			new_common_entry->common_params.cep.entry_name;
 
 		HASHTABLE_INIT(&(new_common_entry->items),
 			struct cache_ht_item_data_, data,
@@ -617,12 +619,12 @@ register_cache_entry(struct cache_ *the_
 		new_mp_entry->params =
 			(struct cache_entry_params *)&new_mp_entry->mp_params;
 
-		new_mp_entry->mp_params.entry_name = (char *)calloc(1,
+		new_mp_entry->mp_params.cep.entry_name = (char *)calloc(1,
 			entry_name_size);
-		assert(new_mp_entry->mp_params.entry_name != NULL);
-		strlcpy(new_mp_entry->mp_params.entry_name, params->entry_name,
+		assert(new_mp_entry->mp_params.cep.entry_name != NULL);
+		strlcpy(new_mp_entry->mp_params.cep.entry_name, params->entry_name,
 			entry_name_size);
-		new_mp_entry->name = new_mp_entry->mp_params.entry_name;
+		new_mp_entry->name = new_mp_entry->mp_params.cep.entry_name;
 
 		TAILQ_INIT(&new_mp_entry->ws_head);
 		TAILQ_INIT(&new_mp_entry->rs_head);
@@ -716,7 +718,6 @@ cache_read(struct cache_entry_ *entry, c
 
 	hash = HASHTABLE_CALCULATE_HASH(cache_ht_, &common_entry->items,
 		&item_data);
-	assert(hash >= 0);
 	assert(hash < HASHTABLE_ENTRIES_COUNT(&common_entry->items));
 
 	item = HASHTABLE_GET_ENTRY(&(common_entry->items), hash);
@@ -820,7 +821,6 @@ cache_write(struct cache_entry_ *entry, 
 
 	hash = HASHTABLE_CALCULATE_HASH(cache_ht_, &common_entry->items,
 		&item_data);
-	assert(hash >= 0);
 	assert(hash < HASHTABLE_ENTRIES_COUNT(&common_entry->items));
 
 	item = HASHTABLE_GET_ENTRY(&(common_entry->items), hash);

Modified: stable/7/usr.sbin/nscd/cachelib.h
==============================================================================
--- stable/7/usr.sbin/nscd/cachelib.h	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/cachelib.h	Sun Jun 21 19:50:06 2009	(r194605)
@@ -29,9 +29,6 @@
 #ifndef __NSCD_CACHELIB_H__
 #define __NSCD_CACHELIB_H__
 
-#include <sys/queue.h>
-#include <sys/time.h>
-#include <stdlib.h>
 #include "hashtable.h"
 #include "cacheplcs.h"
 
@@ -90,11 +87,8 @@ struct cache_entry_params
 /* params, used for most entries */
 struct common_cache_entry_params
 {
-	/* inherited fields */
-	enum cache_entry_t	entry_type;
+	struct cache_entry_params cep;
 
-	/* unique fields */
-	char	*entry_name;
 	size_t	cache_entries_size;
 
 	size_t	max_elemsize;		/* if 0 then no check is made */
@@ -108,9 +102,7 @@ struct common_cache_entry_params
 /* params, used for multipart entries */
 struct	mp_cache_entry_params
 {
-	/* inherited fields */
-	enum cache_entry_t entry_type;
-	char	*entry_name;
+	struct cache_entry_params cep;
 
 	/* unique fields */
 	size_t	max_elemsize;	/* if 0 then no check is made */

Modified: stable/7/usr.sbin/nscd/cacheplcs.c
==============================================================================
--- stable/7/usr.sbin/nscd/cacheplcs.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/cacheplcs.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -28,8 +28,12 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/time.h>
+
 #include <assert.h>
+#include <stdlib.h>
 #include <string.h>
+
 #include "cacheplcs.h"
 #include "debug.h"
 
@@ -55,7 +59,7 @@ static void cache_lru_policy_update_item
 	struct cache_policy_item_ *);
 static void cache_queue_policy_add_item(struct cache_policy_ *,
 	struct cache_policy_item_ *);
-static struct cache_policy_item_ * cache_queue_policy_create_item();
+static struct cache_policy_item_ * cache_queue_policy_create_item(void);
 static void cache_queue_policy_destroy_item(struct cache_policy_item_ *);
 static struct cache_policy_item_ *cache_queue_policy_get_first_item(
 	struct cache_policy_ *);
@@ -77,7 +81,7 @@ static struct cache_queue_policy_ *init_
  * cache_queue_policy_ with cache_update_item function changed.
  */
 static struct cache_policy_item_ *
-cache_queue_policy_create_item()
+cache_queue_policy_create_item(void)
 {
 	struct cache_queue_policy_item_ *retval;
 
@@ -248,7 +252,7 @@ cache_fifo_policy_update_item(struct cac
 }
 
 struct cache_policy_ *
-init_cache_fifo_policy()
+init_cache_fifo_policy(void)
 {
 	struct cache_queue_policy_ *retval;
 
@@ -293,7 +297,7 @@ cache_lru_policy_update_item(struct cach
 }
 
 struct cache_policy_ *
-init_cache_lru_policy()
+init_cache_lru_policy(void)
 {
 	struct cache_queue_policy_ *retval;
 
@@ -530,7 +534,7 @@ cache_lfu_policy_get_prev_item(struct ca
  * functions pointers
  */
 struct cache_policy_ *
-init_cache_lfu_policy()
+init_cache_lfu_policy(void)
 {
 	int i;
 	struct cache_lfu_policy_ *retval;

Modified: stable/7/usr.sbin/nscd/cacheplcs.h
==============================================================================
--- stable/7/usr.sbin/nscd/cacheplcs.h	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/cacheplcs.h	Sun Jun 21 19:50:06 2009	(r194605)
@@ -30,8 +30,6 @@
 #define __NSCD_CACHEPLCS_H__
 
 #include <sys/queue.h>
-#include <sys/time.h>
-#include <stdlib.h>
 
 /* common policy definitions */
 #define CACHELIB_MAX_FREQUENCY 100
@@ -59,7 +57,7 @@ struct cache_policy_item_
  */
 struct cache_policy_
 {
-	struct cache_policy_item_* (*create_item_func)();
+	struct cache_policy_item_* (*create_item_func)(void);
 	void (*destroy_item_func)(struct cache_policy_item_ *);
 
 	void (*add_item_func)(struct cache_policy_ *,
@@ -123,15 +121,15 @@ typedef struct cache_queue_policy_ cache
 typedef struct cache_queue_policy_ cache_lru_policy_;
 
 /* fifo policy routines */
-extern struct cache_policy_ *init_cache_fifo_policy();
+extern struct cache_policy_ *init_cache_fifo_policy(void);
 extern void destroy_cache_fifo_policy(struct cache_policy_ *);
 
 /* lru policy routines */
-extern struct cache_policy_ *init_cache_lru_policy();
+extern struct cache_policy_ *init_cache_lru_policy(void);
 extern void destroy_cache_lru_policy(struct cache_policy_ *);
 
 /* lfu policy routines */
-extern struct cache_policy_ *init_cache_lfu_policy();
+extern struct cache_policy_ *init_cache_lfu_policy(void);
 extern void destroy_cache_lfu_policy(struct cache_policy_ *);
 
 #endif

Modified: stable/7/usr.sbin/nscd/config.c
==============================================================================
--- stable/7/usr.sbin/nscd/config.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/config.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -28,11 +28,17 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/stat.h>
+#include <sys/time.h>
+
 #include <assert.h>
 #include <math.h>
+#include <nsswitch.h>
+#include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
 #include "config.h"
 #include "debug.h"
 #include "log.h"
@@ -170,14 +176,14 @@ create_configuration_entry(const char *n
 	memcpy(&retval->mp_query_timeout, mp_timeout,
 		sizeof(struct timeval));
 
-	asprintf(&retval->positive_cache_params.entry_name, "%s+", name);
-	assert(retval->positive_cache_params.entry_name != NULL);
+	asprintf(&retval->positive_cache_params.cep.entry_name, "%s+", name);
+	assert(retval->positive_cache_params.cep.entry_name != NULL);
 
-	asprintf(&retval->negative_cache_params.entry_name, "%s-", name);
-	assert(retval->negative_cache_params.entry_name != NULL);
+	asprintf(&retval->negative_cache_params.cep.entry_name, "%s-", name);
+	assert(retval->negative_cache_params.cep.entry_name != NULL);
 
-	asprintf(&retval->mp_cache_params.entry_name, "%s*", name);
-	assert(retval->mp_cache_params.entry_name != NULL);
+	asprintf(&retval->mp_cache_params.cep.entry_name, "%s*", name);
+	assert(retval->mp_cache_params.cep.entry_name != NULL);
 
 	TRACE_OUT(create_configuration_entry);
 	return (retval);
@@ -198,7 +204,7 @@ create_def_configuration_entry(const cha
 	TRACE_IN(create_def_configuration_entry);
 	memset(&positive_params, 0,
 		sizeof(struct common_cache_entry_params));
-	positive_params.entry_type = CET_COMMON;
+	positive_params.cep.entry_type = CET_COMMON;
 	positive_params.cache_entries_size = DEFAULT_CACHE_HT_SIZE;
 	positive_params.max_elemsize = DEFAULT_POSITIVE_ELEMENTS_SIZE;
 	positive_params.satisf_elemsize = DEFAULT_POSITIVE_ELEMENTS_SIZE / 2;
@@ -220,7 +226,7 @@ create_def_configuration_entry(const cha
 
 	memset(&mp_params, 0,
 		sizeof(struct mp_cache_entry_params));
-	mp_params.entry_type = CET_MULTIPART;
+	mp_params.cep.entry_type = CET_MULTIPART;
 	mp_params.max_elemsize = DEFAULT_MULTIPART_ELEMENTS_SIZE;
 	mp_params.max_sessions = DEFAULT_MULITPART_SESSIONS_SIZE;
 	mp_params.max_lifetime.tv_sec = DEFAULT_MULITPART_LIFETIME;
@@ -242,9 +248,9 @@ destroy_configuration_entry(struct confi
 	pthread_mutex_destroy(&entry->negative_cache_lock);
 	pthread_mutex_destroy(&entry->mp_cache_lock);
 	free(entry->name);
-	free(entry->positive_cache_params.entry_name);
-	free(entry->negative_cache_params.entry_name);
-	free(entry->mp_cache_params.entry_name);
+	free(entry->positive_cache_params.cep.entry_name);
+	free(entry->negative_cache_params.cep.entry_name);
+	free(entry->mp_cache_params.cep.entry_name);
 	free(entry->mp_cache_entries);
 	free(entry);
 	TRACE_OUT(destroy_configuration_entry);
@@ -563,7 +569,8 @@ fill_configuration_defaults(struct confi
 void
 destroy_configuration(struct configuration *config)
 {
-	int	i;
+	unsigned int i;
+
 	TRACE_IN(destroy_configuration);
 	assert(config != NULL);
 	free(config->pidfile_path);

Modified: stable/7/usr.sbin/nscd/config.h
==============================================================================
--- stable/7/usr.sbin/nscd/config.h	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/config.h	Sun Jun 21 19:50:06 2009	(r194605)
@@ -29,11 +29,6 @@
 #ifndef __NSCD_CONFIG_H__
 #define __NSCD_CONFIG_H__
 
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <pthread.h>
-#include <nsswitch.h>
-#include <unistd.h>
 #include "cachelib.h"
 
 #define DEFAULT_QUERY_TIMEOUT		8

Modified: stable/7/usr.sbin/nscd/debug.c
==============================================================================
--- stable/7/usr.sbin/nscd/debug.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/debug.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -29,13 +29,14 @@
 __FBSDID("$FreeBSD$");
 
 #include <stdio.h>
+
 #include "debug.h"
 
 static	int	trace_level = 0;
 static	int	trace_level_bk = 0;
 
 void
-__trace_in(const char *s, const char *f, int l)
+nscd_trace_in(const char *s, const char *f, int l)
 {
 	int i;
 	if (trace_level < TRACE_WANTED)
@@ -50,7 +51,7 @@ __trace_in(const char *s, const char *f,
 }
 
 void
-__trace_point(const char *f, int l)
+nscd_trace_point(const char *f, int l)
 {
 	int i;
 
@@ -64,7 +65,7 @@ __trace_point(const char *f, int l)
 }
 
 void
-__trace_msg(const char *msg, const char *f, int l)
+nscd_trace_msg(const char *msg, const char *f, int l)
 {
 	int i;
 
@@ -78,7 +79,7 @@ __trace_msg(const char *msg, const char 
 }
 
 void
-__trace_ptr(const char *desc, const void *p, const char *f, int l)
+nscd_trace_ptr(const char *desc, const void *p, const char *f, int l)
 {
 	int i;
 
@@ -92,7 +93,7 @@ __trace_ptr(const char *desc, const void
 }
 
 void
-__trace_int(const char *desc, int i, const char *f, int l)
+nscd_trace_int(const char *desc, int i, const char *f, int l)
 {
 	int j;
 
@@ -106,7 +107,7 @@ __trace_int(const char *desc, int i, con
 }
 
 void
-__trace_str(const char *desc, const char *s, const char *f, int l)
+nscd_trace_str(const char *desc, const char *s, const char *f, int l)
 {
 	int i;
 
@@ -120,7 +121,7 @@ __trace_str(const char *desc, const char
 }
 
 void
-__trace_out(const char *s, const char *f, int l)
+nscd_trace_out(const char *s, const char *f, int l)
 {
 	int i;
 
@@ -135,14 +136,14 @@ __trace_out(const char *s, const char *f
 }
 
 void
-__trace_on()
+nscd_trace_on(void)
 {
 	trace_level = trace_level_bk;
 	trace_level_bk = 0;
 }
 
 void
-__trace_off()
+nscd_trace_off(void)
 {
 	trace_level_bk = trace_level;
 	trace_level = 1024;

Modified: stable/7/usr.sbin/nscd/debug.h
==============================================================================
--- stable/7/usr.sbin/nscd/debug.h	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/debug.h	Sun Jun 21 19:50:06 2009	(r194605)
@@ -33,35 +33,35 @@
 
 /* #ifndef NDEBUG */
 #if 0
-#define TRACE_IN(x)	__trace_in(#x, __FILE__, __LINE__)
-#define TRACE_POINT()	__trace_point(__FILE__, __LINE__)
-#define TRACE_MSG(x)	__trace_msg(x, __FILE__, __LINE__)
-#define TRACE_PTR(p)	__trace_ptr(#p, p, __FILE__, __LINE__)
-#define TRACE_INT(i)	__trace_int(#i, i, __FILE__, __LINE__)
-#define TRACE_STR(s)	__trace_str(#s, s, __FILE__, __LINE__)
-#define TRACE_OUT(x)	__trace_out(#x, __FILE__, __LINE__)
-#define TRACE_ON()	__trace_on()
-#define TRACE_OFF()	__trace_off()
+#define TRACE_IN(x)	nscd_trace_in(#x, __FILE__, __LINE__)
+#define TRACE_POINT()	nscd_trace_point(__FILE__, __LINE__)
+#define TRACE_MSG(x)	nscd_trace_msg(x, __FILE__, __LINE__)
+#define TRACE_PTR(p)	nscd_trace_ptr(#p, p, __FILE__, __LINE__)
+#define TRACE_INT(i)	nscd_trace_int(#i, i, __FILE__, __LINE__)
+#define TRACE_STR(s)	nscd_trace_str(#s, s, __FILE__, __LINE__)
+#define TRACE_OUT(x)	nscd_trace_out(#x, __FILE__, __LINE__)
+#define TRACE_ON()	nscd_trace_on()
+#define TRACE_OFF()	nscd_trace_off()
 #else
-#define TRACE_IN(x)
-#define TRACE_POINT()
-#define TRACE_MSG(x)
-#define TRACE_PTR(p)
-#define TRACE_INT(i)
-#define TRACE_STR(s)
-#define TRACE_OUT(x)
-#define TRACE_ON()
-#define TRACE_OFF()
+#define TRACE_IN(x)	(void)0
+#define TRACE_POINT()	(void)0
+#define TRACE_MSG(x)	(void)0
+#define TRACE_PTR(p)	(void)0
+#define TRACE_INT(i)	(void)0
+#define TRACE_STR(s)	(void)0
+#define TRACE_OUT(x)	(void)0
+#define TRACE_ON()	(void)0
+#define TRACE_OFF()	(void)0
 #endif
 
-extern void __trace_in(const char *, const char *, int);
-extern void __trace_point(const char *, int);
-extern void __trace_msg(const char *, const char *, int);
-extern void __trace_ptr(const char *, const void *, const char *, int);
-extern void __trace_int(const char *, int, const char *, int);
-extern void __trace_str(const char *, const char *, const char *, int);
-extern void __trace_out(const char *, const char *, int);
-extern void __trace_on();
-extern void __trace_off();
+extern void nscd_trace_in(const char *, const char *, int);
+extern void nscd_trace_point(const char *, int);
+extern void nscd_trace_msg(const char *, const char *, int);
+extern void nscd_trace_ptr(const char *, const void *, const char *, int);
+extern void nscd_trace_int(const char *, int, const char *, int);
+extern void nscd_trace_str(const char *, const char *, const char *, int);
+extern void nscd_trace_out(const char *, const char *, int);
+extern void nscd_trace_on(void);
+extern void nscd_trace_off(void);
 
 #endif

Modified: stable/7/usr.sbin/nscd/hashtable.h
==============================================================================
--- stable/7/usr.sbin/nscd/hashtable.h	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/hashtable.h	Sun Jun 21 19:50:06 2009	(r194605)
@@ -29,11 +29,10 @@
 #ifndef __CACHELIB_HASHTABLE_H__
 #define __CACHELIB_HASHTABLE_H__
 
-#include <search.h>
 #include <string.h>
 
 #define HASHTABLE_INITIAL_ENTRIES_CAPACITY 8
-typedef int hashtable_index_t;
+typedef unsigned int hashtable_index_t;
 
 /*
  * This file contains queue.h-like macro definitions for hash tables.

Modified: stable/7/usr.sbin/nscd/log.c
==============================================================================
--- stable/7/usr.sbin/nscd/log.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/log.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include <stdio.h>
 #include <stdlib.h>
 #include <syslog.h>
+
 #include "log.h"
 
 void

Modified: stable/7/usr.sbin/nscd/mp_rs_query.c
==============================================================================
--- stable/7/usr.sbin/nscd/mp_rs_query.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/mp_rs_query.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -28,15 +28,17 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <sys/socket.h>
-#include <sys/time.h>
 #include <sys/types.h>
 #include <sys/event.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+
 #include <assert.h>
 #include <errno.h>
+#include <nsswitch.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdio.h>
 
 #include "cachelib.h"
 #include "config.h"
@@ -138,7 +140,7 @@ on_mp_read_session_request_read2(struct 
 	result = qstate->read_func(qstate, c_mp_rs_request->entry,
 		c_mp_rs_request->entry_length);
 
-	if (result != qstate->kevent_watermark) {
+	if (result < 0 || (size_t)result != qstate->kevent_watermark) {
 		LOG_ERR_3("on_mp_read_session_request_read2",
 			"read failed");
 		TRACE_OUT(on_mp_read_session_request_read2);
@@ -196,7 +198,7 @@ on_mp_read_session_request_process(struc
 
 	if (qstate->config_entry->perform_actual_lookups != 0)
 		dec_cache_entry_name = strdup(
-			qstate->config_entry->mp_cache_params.entry_name);
+			qstate->config_entry->mp_cache_params.cep.entry_name);
 	else {
 #ifdef NS_NSCD_EID_CHECKING
 		if (check_query_eids(qstate) != 0) {
@@ -206,7 +208,7 @@ on_mp_read_session_request_process(struc
 #endif
 
 		asprintf(&dec_cache_entry_name, "%s%s", qstate->eid_str,
-			qstate->config_entry->mp_cache_params.entry_name);
+			qstate->config_entry->mp_cache_params.cep.entry_name);
 	}
 
 	assert(dec_cache_entry_name != NULL);
@@ -461,7 +463,7 @@ on_mp_read_session_read_response_write1(
 	if (read_response->error_code == 0) {
 		result += qstate->write_func(qstate, &read_response->data_size,
 			sizeof(size_t));
-		if (result != qstate->kevent_watermark) {
+		if (result < 0 || (size_t)result != qstate->kevent_watermark) {
 			TRACE_OUT(on_mp_read_session_read_response_write1);
 			LOG_ERR_3("on_mp_read_session_read_response_write1",
 				"write failed");
@@ -471,7 +473,7 @@ on_mp_read_session_read_response_write1(
 		qstate->kevent_watermark = read_response->data_size;
 		qstate->process_func = on_mp_read_session_read_response_write2;
 	} else {
-		if (result != qstate->kevent_watermark) {
+		if (result < 0 || (size_t)result != qstate->kevent_watermark) {
 			LOG_ERR_3("on_mp_read_session_read_response_write1",
 				"write failed");
 			TRACE_OUT(on_mp_read_session_read_response_write1);
@@ -497,7 +499,7 @@ on_mp_read_session_read_response_write2(
 		&qstate->response);
 	result = qstate->write_func(qstate, read_response->data,
 		read_response->data_size);
-	if (result != qstate->kevent_watermark) {
+	if (result < 0 || (size_t)result != qstate->kevent_watermark) {
 		LOG_ERR_3("on_mp_read_session_read_response_write2",
 			"write failed");
 		TRACE_OUT(on_mp_read_session_read_response_write2);

Modified: stable/7/usr.sbin/nscd/mp_ws_query.c
==============================================================================
--- stable/7/usr.sbin/nscd/mp_ws_query.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/mp_ws_query.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -28,15 +28,16 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <sys/socket.h>
-#include <sys/time.h>
 #include <sys/types.h>
 #include <sys/event.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+
 #include <assert.h>
 #include <errno.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdio.h>
 
 #include "cachelib.h"
 #include "config.h"
@@ -144,7 +145,7 @@ on_mp_write_session_request_read2(struct
 	result = qstate->read_func(qstate, c_mp_ws_request->entry,
 		c_mp_ws_request->entry_length);
 
-	if (result != qstate->kevent_watermark) {
+	if (result < 0 || (size_t)result != qstate->kevent_watermark) {
 		LOG_ERR_3("on_mp_write_session_request_read2",
 			"read failed");
 		TRACE_OUT(on_mp_write_session_request_read2);
@@ -215,7 +216,7 @@ on_mp_write_session_request_process(stru
 	 * cache entries - each with its own decorated name.
 	 */
 	asprintf(&dec_cache_entry_name, "%s%s", qstate->eid_str,
-		qstate->config_entry->mp_cache_params.entry_name);
+		qstate->config_entry->mp_cache_params.cep.entry_name);
 	assert(dec_cache_entry_name != NULL);
 
 	configuration_lock_rdlock(s_configuration);
@@ -396,7 +397,7 @@ on_mp_write_session_write_request_read2(
 	result = qstate->read_func(qstate, write_request->data,
 		write_request->data_size);
 
-	if (result != qstate->kevent_watermark) {
+	if (result < 0 || (size_t)result != qstate->kevent_watermark) {
 		LOG_ERR_3("on_mp_write_session_write_request_read2",
 			"read failed");
 		TRACE_OUT(on_mp_write_session_write_request_read2);
@@ -521,12 +522,12 @@ cache_entry register_new_mp_cache_entry(
 	configuration_lock_entry(qstate->config_entry, CELT_MULTIPART);
 
 	configuration_lock_wrlock(s_configuration);
-	en_bkp = qstate->config_entry->mp_cache_params.entry_name;
-	qstate->config_entry->mp_cache_params.entry_name =
+	en_bkp = qstate->config_entry->mp_cache_params.cep.entry_name;
+	qstate->config_entry->mp_cache_params.cep.entry_name =
 		(char *)dec_cache_entry_name;
 	register_cache_entry(s_cache, (struct cache_entry_params *)
 		&qstate->config_entry->mp_cache_params);
-	qstate->config_entry->mp_cache_params.entry_name = en_bkp;
+	qstate->config_entry->mp_cache_params.cep.entry_name = en_bkp;
 	configuration_unlock(s_configuration);
 
 	configuration_lock_rdlock(s_configuration);

Modified: stable/7/usr.sbin/nscd/nscd.c
==============================================================================
--- stable/7/usr.sbin/nscd/nscd.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/nscd.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -28,12 +28,13 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/event.h>
 #include <sys/socket.h>
+#include <sys/stat.h>
 #include <sys/time.h>
-#include <sys/param.h>
 #include <sys/un.h>
+
 #include <assert.h>
 #include <err.h>
 #include <errno.h>
@@ -122,14 +123,14 @@ init_cache_(struct configuration *config
 		res = register_cache_entry(retval, (struct cache_entry_params *)
 			&config_entry->positive_cache_params);
 		config_entry->positive_cache_entry = find_cache_entry(retval,
-			config_entry->positive_cache_params.entry_name);
+			config_entry->positive_cache_params.cep.entry_name);
 		assert(config_entry->positive_cache_entry !=
 			INVALID_CACHE_ENTRY);
 
 		res = register_cache_entry(retval, (struct cache_entry_params *)
 			&config_entry->negative_cache_params);
 		config_entry->negative_cache_entry = find_cache_entry(retval,
-			config_entry->negative_cache_params.entry_name);
+			config_entry->negative_cache_params.cep.entry_name);
 		assert(config_entry->negative_cache_entry !=
 			INVALID_CACHE_ENTRY);
 	}
@@ -315,9 +316,9 @@ process_socket_event(struct kevent *even
 	 * operations. It also does the actual socket IO operations.
 	 */
 	if (((qstate->use_alternate_io == 0) &&
-		(qstate->kevent_watermark <= event_data->data)) ||
+		(qstate->kevent_watermark <= (size_t)event_data->data)) ||
 		((qstate->use_alternate_io != 0) &&
-		(qstate->io_buffer_watermark <= event_data->data))) {
+		(qstate->io_buffer_watermark <= (size_t)event_data->data))) {
 		if (qstate->use_alternate_io != 0) {
 			switch (qstate->io_buffer_filter) {
 			case EVFILT_READ:
@@ -499,7 +500,7 @@ processing_loop(cache the_cache, struct 
 			struct kevent *event_data;
 			event_data = &eventlist[0];
 
-			if (event_data->ident == env->sockfd) {
+			if ((int)event_data->ident == env->sockfd) {
 				for (i = 0; i < event_data->data; ++i)
 				    accept_connection(event_data, env, config);
 
@@ -573,17 +574,17 @@ get_time_func(struct timeval *time)
 }
 
 /*
- * The idea of _nss_cache_cycle_prevention_function is that nsdispatch will
- * search for this symbol in the executable. This symbol is the attribute of
- * the caching daemon. So, if it exists, nsdispatch won't try to connect to
- * the caching daemon and will just ignore the 'cache' source in the
- * nsswitch.conf. This method helps to avoid cycles and organize
- * self-performing requests.
+ * The idea of _nss_cache_cycle_prevention_function is that nsdispatch
+ * will search for this symbol in the executable. This symbol is the
+ * attribute of the caching daemon. So, if it exists, nsdispatch won't try
+ * to connect to the caching daemon and will just ignore the 'cache'
+ * source in the nsswitch.conf. This method helps to avoid cycles and
+ * organize self-performing requests.
+ *
+ * (not actually a function; it used to be, but it doesn't make any
+ * difference, as long as it has external linkage)
  */
-void
-_nss_cache_cycle_prevention_function(void)
-{
-}
+void *_nss_cache_cycle_prevention_function;
 
 int
 main(int argc, char *argv[])

Modified: stable/7/usr.sbin/nscd/nscdcli.c
==============================================================================
--- stable/7/usr.sbin/nscd/nscdcli.c	Sun Jun 21 19:39:34 2009	(r194604)
+++ stable/7/usr.sbin/nscd/nscdcli.c	Sun Jun 21 19:50:06 2009	(r194605)
@@ -29,10 +29,12 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
-#include <sys/socket.h>
+
 #include <sys/event.h>
+#include <sys/socket.h>
 #include <sys/uio.h>
 #include <sys/un.h>
+
 #include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -70,9 +72,10 @@ safe_write(struct nscd_connection_ *conn
 		nevents = kevent(connection->write_queue, NULL, 0, &eventlist,
 	    		1, &timeout);
 		if ((nevents == 1) && (eventlist.filter == EVFILT_WRITE)) {
-			s_result = write(connection->sockfd, data + result,
-				eventlist.data < data_size - result ?
-		    		eventlist.data : data_size - result);
+			s_result = write(connection->sockfd,
+				(char *)data + result,
+				(size_t)eventlist.data < data_size - result ?
+		    		(size_t)eventlist.data : data_size - result);
 			if (s_result == -1)
 				return (-1);
 			else
@@ -106,9 +109,10 @@ safe_read(struct nscd_connection_ *conne
 		nevents = kevent(connection->read_queue, NULL, 0, &eventlist, 1,
 			&timeout);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-stable-7 mailing list