Module Name:    src
Committed By:   christos
Date:           Fri Feb 10 18:06:59 UTC 2017

Modified Files:
        src/external/bsd/file/dist/src: apprentice.c cdf.c compress.c print.c
            readelf.c softmagic.c

Log Message:
pacify lint.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/file/dist/src/apprentice.c
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/file/dist/src/cdf.c \
    src/external/bsd/file/dist/src/readelf.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/file/dist/src/compress.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/file/dist/src/print.c
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/file/dist/src/softmagic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/file/dist/src/apprentice.c
diff -u src/external/bsd/file/dist/src/apprentice.c:1.15 src/external/bsd/file/dist/src/apprentice.c:1.16
--- src/external/bsd/file/dist/src/apprentice.c:1.15	Fri Feb 10 12:53:24 2017
+++ src/external/bsd/file/dist/src/apprentice.c	Fri Feb 10 13:06:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apprentice.c,v 1.15 2017/02/10 17:53:24 christos Exp $	*/
+/*	$NetBSD: apprentice.c,v 1.16 2017/02/10 18:06:59 christos Exp $	*/
 
 /*
  * Copyright (c) Ian F. Darwin 1986-1995.
@@ -37,7 +37,7 @@
 #if 0
 FILE_RCSID("@(#)$File: apprentice.c,v 1.257 2017/02/04 16:46:16 christos Exp $")
 #else
-__RCSID("$NetBSD: apprentice.c,v 1.15 2017/02/10 17:53:24 christos Exp $");
+__RCSID("$NetBSD: apprentice.c,v 1.16 2017/02/10 18:06:59 christos Exp $");
 #endif
 #endif	/* lint */
 
@@ -555,8 +555,10 @@ apprentice_unmap(struct magic_map *map)
 		break;
 	case MAP_TYPE_MALLOC:
 		for (i = 0; i < MAGIC_SETS; i++) {
-			if ((char *)map->magic[i] >= (char *)map->p &&
-			    (char *)map->magic[i] <= (char *)map->p + map->len)
+			void *b = map->magic[i];
+			void *p = map->p;
+			if (CAST(char *, b) >= CAST(char *, p) &&
+			    CAST(char *, b) <= CAST(char *, p) + map->len)
 				continue;
 			free(map->magic[i]);
 		}

Index: src/external/bsd/file/dist/src/cdf.c
diff -u src/external/bsd/file/dist/src/cdf.c:1.12 src/external/bsd/file/dist/src/cdf.c:1.13
--- src/external/bsd/file/dist/src/cdf.c:1.12	Fri Feb 10 12:53:24 2017
+++ src/external/bsd/file/dist/src/cdf.c	Fri Feb 10 13:06:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cdf.c,v 1.12 2017/02/10 17:53:24 christos Exp $	*/
+/*	$NetBSD: cdf.c,v 1.13 2017/02/10 18:06:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 Christos Zoulas
@@ -40,7 +40,7 @@
 #if 0
 FILE_RCSID("@(#)$File: cdf.c,v 1.88 2017/02/07 23:21:29 christos Exp $")
 #else
-__RCSID("$NetBSD: cdf.c,v 1.12 2017/02/10 17:53:24 christos Exp $");
+__RCSID("$NetBSD: cdf.c,v 1.13 2017/02/10 18:06:59 christos Exp $");
 #endif
 #endif
 
@@ -817,7 +817,7 @@ cdf_find_stream(const cdf_dir_t *dir, co
 		    == 0)
 			break;
 	if (i > 0)
-		return i;
+		return CAST(int, i);
 
 	DPRINTF(("Cannot find type %d `%s'\n", type, name));
 	errno = ESRCH;
@@ -1074,7 +1074,7 @@ cdf_unpack_catalog(const cdf_header_t *h
 {
 	size_t ss = cdf_check_stream(sst, h);
 	const char *b = CAST(const char *, sst->sst_tab);
-	const char *eb = b + ss * sst->sst_len;
+	const char *nb, *eb = b + ss * sst->sst_len;
 	size_t nr, i, j, k;
 	cdf_catalog_entry_t *ce;
 	uint16_t reclen;
@@ -1119,7 +1119,9 @@ cdf_unpack_catalog(const cdf_header_t *h
 			cep->ce_namlen = rlen;
 
 		np = CAST(const uint16_t *, CAST(const void *, (b + 16)));
-		if (RCAST(const char *, np + cep->ce_namlen) > eb) {
+		nb = CAST(const char *, CAST(const void *,
+		    (np + cep->ce_namlen)));
+		if (nb > eb) {
 			cep->ce_namlen = 0;
 			break;
 		}
Index: src/external/bsd/file/dist/src/readelf.c
diff -u src/external/bsd/file/dist/src/readelf.c:1.12 src/external/bsd/file/dist/src/readelf.c:1.13
--- src/external/bsd/file/dist/src/readelf.c:1.12	Fri Feb 10 12:53:24 2017
+++ src/external/bsd/file/dist/src/readelf.c	Fri Feb 10 13:06:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: readelf.c,v 1.12 2017/02/10 17:53:24 christos Exp $	*/
+/*	$NetBSD: readelf.c,v 1.13 2017/02/10 18:06:59 christos Exp $	*/
 
 /*
  * Copyright (c) Christos Zoulas 2003.
@@ -32,7 +32,7 @@
 #if 0
 FILE_RCSID("@(#)$File: readelf.c,v 1.130 2017/01/29 19:34:24 christos Exp $")
 #else
-__RCSID("$NetBSD: readelf.c,v 1.12 2017/02/10 17:53:24 christos Exp $");
+__RCSID("$NetBSD: readelf.c,v 1.13 2017/02/10 18:06:59 christos Exp $");
 #endif
 #endif
 
@@ -896,7 +896,7 @@ get_string_on_virtaddr(struct magic_set 
 
 	offset = get_offset_from_virtaddr(ms, swap, clazz, fd, ph_off, ph_num,
 	    fsize, virtaddr);
-	if ((buflen = pread(fd, buf, buflen, offset)) <= 0) {
+	if ((buflen = pread(fd, buf, CAST(size_t, buflen), offset)) <= 0) {
 		file_badread(ms);
 		return 0;
 	}

Index: src/external/bsd/file/dist/src/compress.c
diff -u src/external/bsd/file/dist/src/compress.c:1.11 src/external/bsd/file/dist/src/compress.c:1.12
--- src/external/bsd/file/dist/src/compress.c:1.11	Fri Feb 10 12:53:24 2017
+++ src/external/bsd/file/dist/src/compress.c	Fri Feb 10 13:06:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: compress.c,v 1.11 2017/02/10 17:53:24 christos Exp $	*/
+/*	$NetBSD: compress.c,v 1.12 2017/02/10 18:06:59 christos Exp $	*/
 
 /*
  * Copyright (c) Ian F. Darwin 1986-1995.
@@ -40,7 +40,7 @@
 #if 0
 FILE_RCSID("@(#)$File: compress.c,v 1.101 2017/01/18 16:33:57 christos Exp $")
 #else
-__RCSID("$NetBSD: compress.c,v 1.11 2017/02/10 17:53:24 christos Exp $");
+__RCSID("$NetBSD: compress.c,v 1.12 2017/02/10 18:06:59 christos Exp $");
 #endif
 #endif
 
@@ -100,7 +100,7 @@ static int
 zlibcmp(const unsigned char *buf)
 {
 	unsigned short x = 1;
-	unsigned char *s = (unsigned char *)&x;
+	unsigned char *s = CCAST(unsigned char *, &x);
 
 	if ((buf[0] & 0xf) != 8 || (buf[0] & 0x80) != 0)
 		return 0;
@@ -504,7 +504,7 @@ uncompresszlib(const unsigned char *old,
 	z.next_in = CCAST(Bytef *, old);
 	z.avail_in = CAST(uint32_t, *n);
 	z.next_out = *newch;
-	z.avail_out = bytes_max;
+	z.avail_out = CAST(unsigned int, bytes_max);
 	z.zalloc = Z_NULL;
 	z.zfree = Z_NULL;
 	z.opaque = Z_NULL;
@@ -639,7 +639,7 @@ filter_error(unsigned char *ubuf, ssize_
 		while (isspace((unsigned char)*p))
 			p++;
 		n = strlen(p);
-		memmove(ubuf, p, n + 1);
+		memmove(ubuf, p, CAST(size_t, n + 1));
 	}
 	DPRINTF("Filter error after[[[%s]]]\n", (char *)ubuf);
 	if (islower(*ubuf))
@@ -695,7 +695,7 @@ uncompressbuf(int fd, size_t bytes_max, 
 		}
 		
 		for (i = 0; i < __arraycount(fdp); i++)
-			copydesc(i, fdp[i]);
+			copydesc(CAST(int, i), fdp[i]);
 
 		(void)execvp(compr[method].argv[0],
 		    (char *const *)(intptr_t)compr[method].argv);

Index: src/external/bsd/file/dist/src/print.c
diff -u src/external/bsd/file/dist/src/print.c:1.9 src/external/bsd/file/dist/src/print.c:1.10
--- src/external/bsd/file/dist/src/print.c:1.9	Fri Feb 10 12:53:24 2017
+++ src/external/bsd/file/dist/src/print.c	Fri Feb 10 13:06:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.9 2017/02/10 17:53:24 christos Exp $	*/
+/*	$NetBSD: print.c,v 1.10 2017/02/10 18:06:59 christos Exp $	*/
 
 /*
  * Copyright (c) Ian F. Darwin 1986-1995.
@@ -37,7 +37,7 @@
 #if 0
 FILE_RCSID("@(#)$File: print.c,v 1.81 2016/01/19 15:09:03 christos Exp $")
 #else
-__RCSID("$NetBSD: print.c,v 1.9 2017/02/10 17:53:24 christos Exp $");
+__RCSID("$NetBSD: print.c,v 1.10 2017/02/10 18:06:59 christos Exp $");
 #endif
 #endif  /* lint */
 
@@ -244,7 +244,7 @@ file_fmttime(uint64_t v, int flags, char
 
 	if (flags & FILE_T_WINDOWS) {
 		struct timespec ts;
-		cdf_timestamp_to_timespec(&ts, v);
+		cdf_timestamp_to_timespec(&ts, CAST(cdf_timestamp_t, v));
 		t = ts.tv_sec;
 	} else {
 		// XXX: perhaps detect and print something if overflow

Index: src/external/bsd/file/dist/src/softmagic.c
diff -u src/external/bsd/file/dist/src/softmagic.c:1.14 src/external/bsd/file/dist/src/softmagic.c:1.15
--- src/external/bsd/file/dist/src/softmagic.c:1.14	Fri Feb 10 12:53:24 2017
+++ src/external/bsd/file/dist/src/softmagic.c	Fri Feb 10 13:06:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: softmagic.c,v 1.14 2017/02/10 17:53:24 christos Exp $	*/
+/*	$NetBSD: softmagic.c,v 1.15 2017/02/10 18:06:59 christos Exp $	*/
 
 /*
  * Copyright (c) Ian F. Darwin 1986-1995.
@@ -37,7 +37,7 @@
 #if 0
 FILE_RCSID("@(#)$File: softmagic.c,v 1.243 2017/02/07 23:27:32 christos Exp $")
 #else
-__RCSID("$NetBSD: softmagic.c,v 1.14 2017/02/10 17:53:24 christos Exp $");
+__RCSID("$NetBSD: softmagic.c,v 1.15 2017/02/10 18:06:59 christos Exp $");
 #endif
 #endif	/* lint */
 
@@ -1023,9 +1023,8 @@ private int
 mconvert(struct magic_set *ms, struct magic *m, int flip)
 {
 	union VALUETYPE *p = &ms->ms_value;
-	uint8_t type;
 
-	switch (type = cvt_flip(m->type, flip)) {
+	switch (cvt_flip(m->type, flip)) {
 	case FILE_BYTE:
 		if (cvt_8(p, m) == -1)
 			goto out;
@@ -1190,7 +1189,7 @@ mcopy(struct magic_set *ms, union VALUET
 		case FILE_DER:
 		case FILE_SEARCH:
 			if (offset > nbytes)
-				offset = nbytes;
+				offset = CAST(uint32_t, nbytes);
 			ms->search.s = RCAST(const char *, s) + offset;
 			ms->search.s_len = nbytes - offset;
 			ms->search.offset = offset;

Reply via email to