From: Matthew Dillon Date: Wed, 3 Oct 2007 18:58:20 +0000 (+0000) Subject: libiconv was declaring a base kobj_class structure instead of an extended X-Git-Tag: v2.0.1~2086 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/bef85e27e61aad066c31be44a092b82e024958ee libiconv was declaring a base kobj_class structure instead of an extended kobj_class structure (which it calls iconv_converter_class). Add a new KOBJ macro to allow an extended structure to be declared and explicitly require the full name of the extended structure to be specified by the caller. This bug was causing sysctl -a to crash the system when libiconv.ko is loaded. Reported-by: Rumko , Joerg Anslik --- diff --git a/sys/sys/iconv.h b/sys/sys/iconv.h index 3dbaa8683c..322479c724 100644 --- a/sys/sys/iconv.h +++ b/sys/sys/iconv.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/sys/iconv.h,v 1.1.2.1 2001/05/21 08:28:07 bp Exp $ - * $DragonFly: src/sys/sys/iconv.h,v 1.5 2006/12/23 00:27:03 swildner Exp $ + * $DragonFly: src/sys/sys/iconv.h,v 1.6 2007/10/03 18:58:20 dillon Exp $ */ #ifndef _SYS_ICONV_H_ #define _SYS_ICONV_H_ @@ -111,8 +111,10 @@ struct iconv_cspair { TAILQ_ENTRY(iconv_cspair) cp_link; }; -#define KICONV_CONVERTER(name,size) \ - static DEFINE_CLASS(iconv_ ## name, iconv_ ## name ## _methods, (size)); \ +#define KICONV_CONVERTER(name,size) \ + static DEFINE_CLASS_EXT(iconv_ ## name, iconv_ ## name ## _class, \ + iconv_ ## name ## _methods, \ + (size), iconv_converter_class); \ static moduledata_t iconv_ ## name ## _mod = { \ "iconv_"#name, iconv_converter_handler, \ (void*)&iconv_ ## name ## _class \ diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h index 7a6cf1537b..80ee5bc380 100644 --- a/sys/sys/kobj.h +++ b/sys/sys/kobj.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/sys/kobj.h,v 1.8 2003/09/22 21:32:49 peter Exp $ - * $DragonFly: src/sys/sys/kobj.h,v 1.10 2006/05/20 02:42:13 dillon Exp $ + * $DragonFly: src/sys/sys/kobj.h,v 1.11 2007/10/03 18:58:20 dillon Exp $ */ #ifndef _SYS_KOBJ_H_ @@ -126,6 +126,16 @@ struct kobj_class classvar = { \ #name, methods, size, NULL, 0, NULL \ } +/* + * Define a class with no base classes using the named structure + * as an extension of the kobj_class structure. + */ +#define DEFINE_CLASS_EXT(name, classvar, methods, size, extname) \ + \ +struct extname classvar = { \ + #name, methods, size, NULL, 0, NULL \ +} + /* * Define a class inheriting a single base class. Use like this: *