Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Aug 2006 02:26:41 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 103948 for review
Message-ID:  <200608150226.k7F2Qfrn083657@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=103948

Change 103948 by jb@jb_freebsd2 on 2006/08/15 02:25:45

	Declare the constructor.
	
	Fix compiler warnings.

Affected files ...

.. //depot/projects/dtrace/src/contrib/opensolaris/lib/libctf/common/ctf_lib.c#5 edit

Differences ...

==== //depot/projects/dtrace/src/contrib/opensolaris/lib/libctf/common/ctf_lib.c#5 (text) ====

@@ -29,6 +29,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
+#include <sys/zmod.h>
 #if	!defined(sun)
 #include <opensolaris/compat/sys/mman.h>
 #endif
@@ -58,7 +59,11 @@
 static size_t _PAGESIZE;
 static size_t _PAGEMASK;
 
+#if defined(sun)
 #pragma init(_libctf_init)
+#else
+void    _libctf_init(void) __attribute__ ((constructor));
+#endif
 void
 _libctf_init(void)
 {
@@ -92,8 +97,8 @@
 	if ((zlib.z_dlp = dlopen(_libctf_zlib, RTLD_LAZY | RTLD_LOCAL)) == NULL)
 		return (ctf_set_open_errno(errp, ECTF_ZINIT));
 
-	zlib.z_uncompress = (int (*)()) dlsym(zlib.z_dlp, "uncompress");
-	zlib.z_error = (const char *(*)()) dlsym(zlib.z_dlp, "zError");
+	zlib.z_uncompress = (int (*)(uchar_t *, ulong_t *, const uchar_t *, ulong_t)) dlsym(zlib.z_dlp, "uncompress");
+	zlib.z_error = (const char *(*)(int)) dlsym(zlib.z_dlp, "zError");
 
 	if (zlib.z_uncompress == NULL || zlib.z_error == NULL) {
 		(void) dlclose(zlib.z_dlp);
@@ -227,7 +232,7 @@
 	 * If we have read enough bytes to form a CTF header and the magic
 	 * string matches, attempt to interpret the file as raw CTF.
 	 */
-	if (nbytes >= sizeof (ctf_preamble_t) &&
+	if (nbytes >= (ssize_t) sizeof (ctf_preamble_t) &&
 	    hdr.ctf.ctp_magic == CTF_MAGIC) {
 		if (hdr.ctf.ctp_version > CTF_VERSION)
 			return (ctf_set_open_errno(errp, ECTF_CTFVERS));
@@ -257,7 +262,7 @@
 	 * do our own largefile ELF processing, and convert everything to
 	 * GElf structures so that clients can operate on any data model.
 	 */
-	if (nbytes >= sizeof (Elf32_Ehdr) &&
+	if (nbytes >= (ssize_t) sizeof (Elf32_Ehdr) &&
 	    bcmp(&hdr.e32.e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) {
 #ifdef	_BIG_ENDIAN
 		uchar_t order = ELFDATA2MSB;
@@ -269,7 +274,7 @@
 
 		void *strs_map;
 		size_t strs_mapsz;
-		const char *strs;
+		char *strs;
 
 		if (hdr.e32.e_ident[EI_DATA] != order)
 			return (ctf_set_open_errno(errp, ECTF_ENDIAN));
@@ -277,7 +282,7 @@
 			return (ctf_set_open_errno(errp, ECTF_ELFVERS));
 
 		if (hdr.e32.e_ident[EI_CLASS] == ELFCLASS64) {
-			if (nbytes < sizeof (GElf_Ehdr))
+			if (nbytes < (ssize_t) sizeof (GElf_Ehdr))
 				return (ctf_set_open_errno(errp, ECTF_FMT));
 		} else {
 			Elf32_Ehdr e32 = hdr.e32;
@@ -328,7 +333,7 @@
 		strs_map = mmap64(NULL, strs_mapsz, PROT_READ, MAP_PRIVATE,
 		    fd, sp[hdr.e64.e_shstrndx].sh_offset & _PAGEMASK);
 
-		strs = (const char *)strs_map +
+		strs = (char *)strs_map +
 		    (sp[hdr.e64.e_shstrndx].sh_offset & ~_PAGEMASK);
 
 		if (strs_map == MAP_FAILED) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608150226.k7F2Qfrn083657>