From owner-svn-src-head@FreeBSD.ORG Fri May 27 08:42:41 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54F041065672; Fri, 27 May 2011 08:42:41 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 0C3AD8FC08; Fri, 27 May 2011 08:42:39 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id LAA04784; Fri, 27 May 2011 11:42:38 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1QPscw-0003UM-9o; Fri, 27 May 2011 11:42:38 +0300 Message-ID: <4DDF63FD.8040205@FreeBSD.org> Date: Fri, 27 May 2011 11:42:37 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.17) Gecko/20110503 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: Pawel Jakub Dawidek References: <201105270834.p4R8YVS8007972@svn.freebsd.org> In-Reply-To: <201105270834.p4R8YVS8007972@svn.freebsd.org> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r222343 - head/sys/cddl/compat/opensolaris/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2011 08:42:41 -0000 on 27/05/2011 11:34 Pawel Jakub Dawidek said the following: > Author: pjd > Date: Fri May 27 08:34:31 2011 > New Revision: 222343 > URL: http://svn.freebsd.org/changeset/base/222343 > > Log: > Silence warnings about unsupoorted value types. > > MFC after: 2 weeks BTW, I've just came with this patch for type 19 in particular, haven't even tested it yet :-) diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_sysevent.c b/sys/cddl/compat/opensolaris/kern/opensolaris_sysevent.c index dea618c..12b9e22 100644 --- a/sys/cddl/compat/opensolaris/kern/opensolaris_sysevent.c +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_sysevent.c @@ -157,26 +157,15 @@ sysevent_detach_attributes(sysevent_t *evp) ev->se_nvl = NULL; } -int -log_sysevent(sysevent_t *evp, int flag, sysevent_id_t *eid) +static void +print_nvlist_sbuf(nvlist_t *nvl, struct sbuf *sb, const char **type) { - struct sysevent *ev = (struct sysevent *)evp; - struct sbuf *sb; - const char *type; - char typestr[128]; nvpair_t *elem = NULL; - ASSERT(evp != NULL); - ASSERT(ev->se_nvl != NULL); - ASSERT(flag == SE_SLEEP); - ASSERT(eid != NULL); + if (type != NULL) + *type = NULL; - sb = sbuf_new_auto(); - if (sb == NULL) - return (SE_ENOMEM); - type = NULL; - - while ((elem = nvlist_next_nvpair(ev->se_nvl, elem)) != NULL) { + while ((elem = nvlist_next_nvpair(nvl, elem)) != NULL) { switch (nvpair_type(elem)) { case DATA_TYPE_BOOLEAN: { @@ -237,13 +226,24 @@ log_sysevent(sysevent_t *evp, int flag, sysevent_id_t *eid) (void) nvpair_value_string(elem, &value); sbuf_printf(sb, " %s=%s", nvpair_name(elem), value); - if (strcmp(FM_CLASS, nvpair_name(elem)) == 0) - type = value; + if (type != NULL && + strcmp(FM_CLASS, nvpair_name(elem)) == 0) + *type = value; + break; + } + case DATA_TYPE_NVLIST: + { + nvlist_t *value; + + (void) nvpair_value_nvlist(elem, &value); + sbuf_printf(sb, " %s=[", nvpair_name(elem)); + print_nvlist_sbuf(value, sb, NULL); + sbuf_printf(sb, "]"); break; } case DATA_TYPE_UINT8_ARRAY: { - uint8_t *value; + uint8_t *value; uint_t ii, nelem; (void) nvpair_value_uint8_array(elem, &value, &nelem); @@ -254,7 +254,7 @@ log_sysevent(sysevent_t *evp, int flag, sysevent_id_t *eid) } case DATA_TYPE_UINT16_ARRAY: { - uint16_t *value; + uint16_t *value; uint_t ii, nelem; (void) nvpair_value_uint16_array(elem, &value, &nelem); @@ -265,7 +265,7 @@ log_sysevent(sysevent_t *evp, int flag, sysevent_id_t *eid) } case DATA_TYPE_UINT32_ARRAY: { - uint32_t *value; + uint32_t *value; uint_t ii, nelem; (void) nvpair_value_uint32_array(elem, &value, &nelem); @@ -276,7 +276,7 @@ log_sysevent(sysevent_t *evp, int flag, sysevent_id_t *eid) } case DATA_TYPE_UINT64_ARRAY: { - uint64_t *value; + uint64_t *value; uint_t ii, nelem; (void) nvpair_value_uint64_array(elem, &value, &nelem); @@ -291,6 +291,26 @@ log_sysevent(sysevent_t *evp, int flag, sysevent_id_t *eid) break; } } +} + +int +log_sysevent(sysevent_t *evp, int flag, sysevent_id_t *eid) +{ + struct sysevent *ev = (struct sysevent *)evp; + struct sbuf *sb; + const char *type; + char typestr[128]; + + ASSERT(evp != NULL); + ASSERT(ev->se_nvl != NULL); + ASSERT(flag == SE_SLEEP); + ASSERT(eid != NULL); + + sb = sbuf_new_auto(); + if (sb == NULL) + return (SE_ENOMEM); + + print_nvlist_sbuf(ev->se_nvl, sb, &type); if (sbuf_finish(sb) != 0) { sbuf_delete(sb); -- Andriy Gapon