Date: Fri, 27 May 2011 11:42:37 +0300 From: Andriy Gapon <avg@FreeBSD.org> To: Pawel Jakub Dawidek <pjd@FreeBSD.org> 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 Message-ID: <4DDF63FD.8040205@FreeBSD.org> In-Reply-To: <201105270834.p4R8YVS8007972@svn.freebsd.org> References: <201105270834.p4R8YVS8007972@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4DDF63FD.8040205>