Date: Sat, 13 Jun 2009 01:22:56 +0000 (UTC) From: Dag-Erling Smorgrav <des@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r194097 - head/usr.sbin/nscd Message-ID: <200906130122.n5D1Mu1O098966@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: des Date: Sat Jun 13 01:22:56 2009 New Revision: 194097 URL: http://svn.freebsd.org/changeset/base/194097 Log: Explain to the compiler why the aliasing we're doing is OK. MFC after: 1 week Modified: head/usr.sbin/nscd/cachelib.c head/usr.sbin/nscd/cachelib.h head/usr.sbin/nscd/config.c head/usr.sbin/nscd/mp_rs_query.c head/usr.sbin/nscd/mp_ws_query.c head/usr.sbin/nscd/nscd.c head/usr.sbin/nscd/query.c Modified: head/usr.sbin/nscd/cachelib.c ============================================================================== --- head/usr.sbin/nscd/cachelib.c Sat Jun 13 00:56:17 2009 (r194096) +++ head/usr.sbin/nscd/cachelib.c Sat Jun 13 01:22:56 2009 (r194097) @@ -565,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, @@ -619,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); Modified: head/usr.sbin/nscd/cachelib.h ============================================================================== --- head/usr.sbin/nscd/cachelib.h Sat Jun 13 00:56:17 2009 (r194096) +++ head/usr.sbin/nscd/cachelib.h Sat Jun 13 01:22:56 2009 (r194097) @@ -87,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 */ @@ -105,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: head/usr.sbin/nscd/config.c ============================================================================== --- head/usr.sbin/nscd/config.c Sat Jun 13 00:56:17 2009 (r194096) +++ head/usr.sbin/nscd/config.c Sat Jun 13 01:22:56 2009 (r194097) @@ -176,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); @@ -204,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; @@ -226,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; @@ -248,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); Modified: head/usr.sbin/nscd/mp_rs_query.c ============================================================================== --- head/usr.sbin/nscd/mp_rs_query.c Sat Jun 13 00:56:17 2009 (r194096) +++ head/usr.sbin/nscd/mp_rs_query.c Sat Jun 13 01:22:56 2009 (r194097) @@ -198,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) { @@ -208,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); Modified: head/usr.sbin/nscd/mp_ws_query.c ============================================================================== --- head/usr.sbin/nscd/mp_ws_query.c Sat Jun 13 00:56:17 2009 (r194096) +++ head/usr.sbin/nscd/mp_ws_query.c Sat Jun 13 01:22:56 2009 (r194097) @@ -216,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); @@ -522,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: head/usr.sbin/nscd/nscd.c ============================================================================== --- head/usr.sbin/nscd/nscd.c Sat Jun 13 00:56:17 2009 (r194096) +++ head/usr.sbin/nscd/nscd.c Sat Jun 13 01:22:56 2009 (r194097) @@ -123,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); } Modified: head/usr.sbin/nscd/query.c ============================================================================== --- head/usr.sbin/nscd/query.c Sat Jun 13 00:56:17 2009 (r194096) +++ head/usr.sbin/nscd/query.c Sat Jun 13 01:22:56 2009 (r194097) @@ -437,7 +437,7 @@ on_write_request_process(struct query_st configuration_lock_rdlock(s_configuration); c_entry = find_cache_entry(s_cache, - qstate->config_entry->positive_cache_params.entry_name); + qstate->config_entry->positive_cache_params.cep.entry_name); configuration_unlock(s_configuration); if (c_entry != NULL) { configuration_lock_entry(qstate->config_entry, CELT_POSITIVE); @@ -518,7 +518,7 @@ on_negative_write_request_process(struct configuration_lock_rdlock(s_configuration); c_entry = find_cache_entry(s_cache, - qstate->config_entry->negative_cache_params.entry_name); + qstate->config_entry->negative_cache_params.cep.entry_name); configuration_unlock(s_configuration); if (c_entry != NULL) { configuration_lock_entry(qstate->config_entry, CELT_NEGATIVE); @@ -710,9 +710,9 @@ on_read_request_process(struct query_sta configuration_lock_rdlock(s_configuration); c_entry = find_cache_entry(s_cache, - qstate->config_entry->positive_cache_params.entry_name); + qstate->config_entry->positive_cache_params.cep.entry_name); neg_c_entry = find_cache_entry(s_cache, - qstate->config_entry->negative_cache_params.entry_name); + qstate->config_entry->negative_cache_params.cep.entry_name); configuration_unlock(s_configuration); if ((c_entry != NULL) && (neg_c_entry != NULL)) { configuration_lock_entry(qstate->config_entry, CELT_POSITIVE);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906130122.n5D1Mu1O098966>