Module Name: src Committed By: christos Date: Fri May 8 17:28:02 UTC 2009
Modified Files: src/external/bsd/file/dist/src: apprentice.c cdf.c cdf_time.c compress.c file.h fsmagic.c funcs.c magic.c readcdf.c readelf.c softmagic.c Added Files: src/external/bsd/file: Makefile.inc src/external/bsd/file/bin: Makefile src/external/bsd/file/include: config.h src/external/bsd/file/lib: Makefile shlib_version Log Message: build glue and lint fixes To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/external/bsd/file/Makefile.inc cvs rdiff -u -r0 -r1.1 src/external/bsd/file/bin/Makefile cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/file/dist/src/apprentice.c \ src/external/bsd/file/dist/src/cdf.c \ src/external/bsd/file/dist/src/cdf_time.c \ src/external/bsd/file/dist/src/compress.c \ src/external/bsd/file/dist/src/file.h \ src/external/bsd/file/dist/src/fsmagic.c \ src/external/bsd/file/dist/src/funcs.c \ src/external/bsd/file/dist/src/magic.c \ src/external/bsd/file/dist/src/readcdf.c \ src/external/bsd/file/dist/src/readelf.c \ src/external/bsd/file/dist/src/softmagic.c cvs rdiff -u -r0 -r1.1 src/external/bsd/file/include/config.h cvs rdiff -u -r0 -r1.1 src/external/bsd/file/lib/Makefile \ src/external/bsd/file/lib/shlib_version 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.1.1.1 src/external/bsd/file/dist/src/apprentice.c:1.2 --- src/external/bsd/file/dist/src/apprentice.c:1.1.1.1 Fri May 8 12:35:05 2009 +++ src/external/bsd/file/dist/src/apprentice.c Fri May 8 13:28:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: apprentice.c,v 1.1.1.1 2009/05/08 16:35:05 christos Exp $ */ +/* $NetBSD: apprentice.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */ /* * Copyright (c) Ian F. Darwin 1986-1995. @@ -37,7 +37,7 @@ #if 0 FILE_RCSID("@(#)$File: apprentice.c,v 1.151 2009/03/18 15:19:23 christos Exp $") #else -__RCSID("$NetBSD: apprentice.c,v 1.1.1.1 2009/05/08 16:35:05 christos Exp $"); +__RCSID("$NetBSD: apprentice.c,v 1.2 2009/05/08 17:28:01 christos Exp $"); #endif #endif /* lint */ @@ -633,7 +633,9 @@ (*errs)++; } else { /* read and parse this file */ - for (ms->line = 1; fgets(line, sizeof(line), f) != NULL; ms->line++) { + for (ms->line = 1; + fgets(line, CAST(int, sizeof(line)), f) != NULL; + ms->line++) { size_t len; len = strlen(line); if (len == 0) /* null line, garbage, etc */ @@ -1093,7 +1095,7 @@ return -1; } me->mp = m = nm; - me->max_count = cnt; + me->max_count = CAST(uint32_t, cnt); } m = &me->mp[me->cont_count++]; (void)memset(m, 0, sizeof(*m)); @@ -1129,7 +1131,7 @@ m->cont_level = 0; me->cont_count = 1; } - m->lineno = lineno; + m->lineno = CAST(uint32_t, lineno); if (*l == '&') { /* m->cont_level == 0 checked below. */ ++l; /* step over */ @@ -1302,7 +1304,8 @@ file_magwarn(ms, "multiple ranges"); have_range = 1; - m->str_range = strtoul(l, &t, 0); + m->str_range = CAST(uint32_t, + strtoul(l, &t, 0)); if (m->str_range == 0) file_magwarn(ms, "zero range"); @@ -1949,7 +1952,7 @@ } out: *p = '\0'; - m->vallen = p - origp; + m->vallen = CAST(unsigned char, (p - origp)); if (m->type == FILE_PSTRING) m->vallen++; return s; Index: src/external/bsd/file/dist/src/cdf.c diff -u src/external/bsd/file/dist/src/cdf.c:1.1.1.1 src/external/bsd/file/dist/src/cdf.c:1.2 --- src/external/bsd/file/dist/src/cdf.c:1.1.1.1 Fri May 8 12:35:06 2009 +++ src/external/bsd/file/dist/src/cdf.c Fri May 8 13:28:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: cdf.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $ */ +/* $NetBSD: cdf.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */ /*- * Copyright (c) 2008 Christos Zoulas @@ -37,7 +37,7 @@ #if 0 FILE_RCSID("@(#)$File: cdf.c,v 1.30 2009/05/06 14:29:47 christos Exp $") #else -__RCSID("$NetBSD: cdf.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $"); +__RCSID("$NetBSD: cdf.c,v 1.2 2009/05/08 17:28:01 christos Exp $"); #endif #endif @@ -74,9 +74,9 @@ #define NEED_SWAP (cdf_bo.u == (uint32_t)0x01020304) -#define CDF_TOLE8(x) (NEED_SWAP ? cdf_tole8(x) : (uint64_t)(x)) -#define CDF_TOLE4(x) (NEED_SWAP ? cdf_tole4(x) : (uint32_t)(x)) -#define CDF_TOLE2(x) (NEED_SWAP ? cdf_tole2(x) : (uint16_t)(x)) +#define CDF_TOLE8(x) ((uint64_t)(NEED_SWAP ? cdf_tole8(x) : (uint64_t)(x))) +#define CDF_TOLE4(x) ((uint32_t)(NEED_SWAP ? cdf_tole4(x) : (uint32_t)(x))) +#define CDF_TOLE2(x) ((uint16_t)(NEED_SWAP ? cdf_tole2(x) : (uint16_t)(x))) /* * swap a short @@ -151,15 +151,15 @@ h->h_min_size_standard_stream = CDF_TOLE4(h->h_min_size_standard_stream); h->h_secid_first_sector_in_short_sat = - CDF_TOLE4(h->h_secid_first_sector_in_short_sat); + CDF_TOLE4((uint32_t)h->h_secid_first_sector_in_short_sat); h->h_num_sectors_in_short_sat = CDF_TOLE4(h->h_num_sectors_in_short_sat); h->h_secid_first_sector_in_master_sat = - CDF_TOLE4(h->h_secid_first_sector_in_master_sat); + CDF_TOLE4((uint32_t)h->h_secid_first_sector_in_master_sat); h->h_num_sectors_in_master_sat = CDF_TOLE4(h->h_num_sectors_in_master_sat); for (i = 0; i < __arraycount(h->h_master_sat); i++) - h->h_master_sat[i] = CDF_TOLE4(h->h_master_sat[i]); + h->h_master_sat[i] = CDF_TOLE4((uint32_t)h->h_master_sat[i]); } void @@ -192,15 +192,15 @@ cdf_swap_dir(cdf_directory_t *d) { d->d_namelen = CDF_TOLE2(d->d_namelen); - d->d_left_child = CDF_TOLE4(d->d_left_child); - d->d_right_child = CDF_TOLE4(d->d_right_child); - d->d_storage = CDF_TOLE4(d->d_storage); + d->d_left_child = CDF_TOLE4((uint32_t)d->d_left_child); + d->d_right_child = CDF_TOLE4((uint32_t)d->d_right_child); + d->d_storage = CDF_TOLE4((uint32_t)d->d_storage); d->d_storage_uuid[0] = CDF_TOLE8(d->d_storage_uuid[0]); d->d_storage_uuid[1] = CDF_TOLE8(d->d_storage_uuid[1]); d->d_flags = CDF_TOLE4(d->d_flags); - d->d_created = CDF_TOLE8(d->d_created); - d->d_modified = CDF_TOLE8(d->d_modified); - d->d_stream_first_sector = CDF_TOLE4(d->d_stream_first_sector); + d->d_created = CDF_TOLE8((uint64_t)d->d_created); + d->d_modified = CDF_TOLE8((uint64_t)d->d_modified); + d->d_stream_first_sector = CDF_TOLE4((uint32_t)d->d_stream_first_sector); d->d_size = CDF_TOLE4(d->d_size); } @@ -380,7 +380,7 @@ goto out2; } for (k = 0; k < nsatpersec; k++, i++) { - sec = CDF_TOLE4(msa[k]); + sec = CDF_TOLE4((uint32_t)msa[k]); if (sec < 0) goto out; if (i >= sat->sat_len) { @@ -396,7 +396,7 @@ goto out2; } } - mid = CDF_TOLE4(msa[nsatpersec]); + mid = CDF_TOLE4((uint32_t)msa[nsatpersec]); } out: sat->sat_len = i; @@ -428,7 +428,7 @@ errno = EFTYPE; return (size_t)-1; } - sid = CDF_TOLE4(sat->sat_tab[sid]); + sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]); } DPRINTF(("\n")); return i; @@ -471,7 +471,7 @@ DPRINTF(("Reading long sector chain %d", sid)); goto out; } - sid = CDF_TOLE4(sat->sat_tab[sid]); + sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]); } return 0; out: @@ -512,7 +512,7 @@ DPRINTF(("Reading short sector chain %d", sid)); goto out; } - sid = CDF_TOLE4(ssat->sat_tab[sid]); + sid = CDF_TOLE4((uint32_t)ssat->sat_tab[sid]); } return 0; out: @@ -572,7 +572,7 @@ cdf_unpack_dir(&dir->dir_tab[i * nd + j], &buf[j * CDF_DIRECTORY_SIZE]); } - sid = CDF_TOLE4(sat->sat_tab[sid]); + sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]); } if (NEED_SWAP) for (i = 0; i < dir->dir_len; i++) @@ -619,7 +619,7 @@ DPRINTF(("Reading short sat sector %d", sid)); goto out; } - sid = CDF_TOLE4(sat->sat_tab[sid]); + sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]); } return 0; out: @@ -739,12 +739,14 @@ *info = inp; inp += *count; *count += sh.sh_properties; - p = (const void *)((const char *)sst->sst_tab + offs + sizeof(sh)); - e = (const void *)(((const char *)shp) + sh.sh_len); + p = (const void *)((const char *)(const void *)sst->sst_tab + + offs + sizeof(sh)); + e = (const void *)(((const char *)(const void *)shp) + sh.sh_len); if (cdf_check_stream_offset(sst, e, 0) == -1) goto out; for (i = 0; i < sh.sh_properties; i++) { - q = (const uint32_t *)((const char *)p + + q = (const uint32_t *)(const void *) + ((const char *)(const void *)p + CDF_TOLE4(p[(i << 1) + 1])) - 2; if (q > e) { DPRINTF(("Ran of the end %p > %p\n", q, e)); @@ -776,7 +778,7 @@ if (inp[i].pi_type & CDF_VECTOR) goto unknown; (void)memcpy(&s32, &q[o], sizeof(s32)); - inp[i].pi_s32 = CDF_TOLE4(s32); + inp[i].pi_s32 = CDF_TOLE4((uint32_t)s32); break; case CDF_BOOL: case CDF_UNSIGNED32: @@ -789,13 +791,13 @@ if (inp[i].pi_type & CDF_VECTOR) goto unknown; (void)memcpy(&s64, &q[o], sizeof(s64)); - inp[i].pi_s64 = CDF_TOLE4(s64); + inp[i].pi_s64 = CDF_TOLE8((uint64_t)s64); break; case CDF_UNSIGNED64: if (inp[i].pi_type & CDF_VECTOR) goto unknown; (void)memcpy(&u64, &q[o], sizeof(u64)); - inp[i].pi_u64 = CDF_TOLE4(u64); + inp[i].pi_u64 = CDF_TOLE8((uint64_t)u64); break; case CDF_LENGTH32_STRING: if (nelements > 1) { @@ -814,11 +816,12 @@ for (j = 0; j < nelements; j++, i++) { uint32_t l = CDF_TOLE4(q[o]); inp[i].pi_str.s_len = l; - inp[i].pi_str.s_buf = (const char *)(&q[o+1]); + inp[i].pi_str.s_buf = + (const char *)(const void *)(&q[o+1]); DPRINTF(("l = %d, r = %d, s = %s\n", l, CDF_ROUND(l, sizeof(l)), inp[i].pi_str.s_buf)); - l = 4 + CDF_ROUND(l, sizeof(l)); + l = 4 + (uint32_t)CDF_ROUND(l, sizeof(l)); o += l >> 2; } i--; @@ -827,7 +830,7 @@ if (inp[i].pi_type & CDF_VECTOR) goto unknown; (void)memcpy(&tp, &q[o], sizeof(tp)); - inp[i].pi_tp = CDF_TOLE8(tp); + inp[i].pi_tp = CDF_TOLE8((uint64_t)tp); break; case CDF_CLIPBOARD: if (inp[i].pi_type & CDF_VECTOR) @@ -932,17 +935,17 @@ int cdf_print_elapsed_time(char *buf, size_t bufsiz, cdf_timestamp_t ts) { - size_t len = 0; + int len = 0; int days, hours, mins, secs; ts /= CDF_TIME_PREC; - secs = ts % 60; + secs = (int)(ts % 60); ts /= 60; - mins = ts % 60; + mins = (int)(ts % 60); ts /= 60; - hours = ts % 24; + hours = (int)(ts % 24); ts /= 24; - days = ts; + days = (int)ts; if (days) { len += snprintf(buf + len, bufsiz - len, "%dd+", days); Index: src/external/bsd/file/dist/src/cdf_time.c diff -u src/external/bsd/file/dist/src/cdf_time.c:1.1.1.1 src/external/bsd/file/dist/src/cdf_time.c:1.2 --- src/external/bsd/file/dist/src/cdf_time.c:1.1.1.1 Fri May 8 12:35:06 2009 +++ src/external/bsd/file/dist/src/cdf_time.c Fri May 8 13:28:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: cdf_time.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $ */ +/* $NetBSD: cdf_time.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */ /*- * Copyright (c) 2008 Christos Zoulas @@ -32,7 +32,7 @@ #if 0 FILE_RCSID("@(#)$File: cdf_time.c,v 1.6 2009/03/10 11:44:29 christos Exp $") #else -__RCSID("$NetBSD: cdf_time.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $"); +__RCSID("$NetBSD: cdf_time.c,v 1.2 2009/05/08 17:28:01 christos Exp $"); #endif #endif @@ -114,22 +114,22 @@ ts->tv_nsec = (t % CDF_TIME_PREC) * 100; t /= CDF_TIME_PREC; - tm.tm_sec = t % 60; + tm.tm_sec = (int)(t % 60); t /= 60; - tm.tm_min = t % 60; + tm.tm_min = (int)(t % 60); t /= 60; - tm.tm_hour = t % 24; + tm.tm_hour = (int)(t % 24); t /= 24; // XXX: Approx - tm.tm_year = CDF_BASE_YEAR + (t / 365); + tm.tm_year = (int)(CDF_BASE_YEAR + (t / 365)); rdays = cdf_getdays(tm.tm_year); t -= rdays; - tm.tm_mday = cdf_getday(tm.tm_year, t); - tm.tm_mon = cdf_getmonth(tm.tm_year, t); + tm.tm_mday = cdf_getday(tm.tm_year, (int)t); + tm.tm_mon = cdf_getmonth(tm.tm_year, (int)t); tm.tm_wday = 0; tm.tm_yday = 0; tm.tm_isdst = 0; @@ -149,10 +149,13 @@ } int +/*ARGSUSED*/ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts) { +#ifndef __lint__ (void)&t; (void)&ts; +#endif #ifdef notyet struct tm tm; if (gmtime_r(&ts->ts_sec, &tm) == NULL) { Index: src/external/bsd/file/dist/src/compress.c diff -u src/external/bsd/file/dist/src/compress.c:1.1.1.1 src/external/bsd/file/dist/src/compress.c:1.2 --- src/external/bsd/file/dist/src/compress.c:1.1.1.1 Fri May 8 12:35:06 2009 +++ src/external/bsd/file/dist/src/compress.c Fri May 8 13:28:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: compress.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $ */ +/* $NetBSD: compress.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */ /* * Copyright (c) Ian F. Darwin 1986-1995. @@ -40,7 +40,7 @@ #if 0 FILE_RCSID("@(#)$File: compress.c,v 1.63 2009/03/23 14:21:51 christos Exp $") #else -__RCSID("$NetBSD: compress.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $"); +__RCSID("$NetBSD: compress.c,v 1.2 2009/05/08 17:28:01 christos Exp $"); #endif #endif @@ -150,7 +150,7 @@ private ssize_t swrite(int fd, const void *buf, size_t n) { - int rv; + ssize_t rv; size_t rn = n; do @@ -161,7 +161,7 @@ return -1; default: n -= rv; - buf = ((const char *)buf) + rv; + buf = CAST(const char *, buf) + rv; break; } while (n > 0); @@ -175,7 +175,7 @@ protected ssize_t sread(int fd, void *buf, size_t n, int canbepipe) { - int rv, cnt; + ssize_t rv, cnt; #ifdef FIONREAD int t = 0; #endif @@ -241,7 +241,8 @@ size_t nbytes) { char buf[4096]; - int r, tfd; + ssize_t r; + int tfd, te; (void)strlcpy(buf, "/tmp/file.XXXXXX", sizeof buf); #ifndef HAVE_MKSTEMP @@ -254,9 +255,9 @@ } #else tfd = mkstemp(buf); - r = errno; + te = errno; (void)unlink(buf); - errno = r; + errno = te; #endif if (tfd == -1) { file_error(ms, errno, @@ -343,13 +344,14 @@ /* XXX: const castaway, via strchr */ z.next_in = (Bytef *)strchr((const char *)old + data_start, old[data_start]); - z.avail_in = n - data_start; + z.avail_in = CAST(uint32_t, (n - data_start)); z.next_out = *newch; z.avail_out = HOWMANY; z.zalloc = Z_NULL; z.zfree = Z_NULL; z.opaque = Z_NULL; + /* LINTED bug in header macro */ rc = inflateInit2(&z, -15); if (rc != Z_OK) { file_error(ms, 0, "zlib: %s", z.msg); @@ -377,7 +379,7 @@ const unsigned char *old, unsigned char **newch, size_t n) { int fdin[2], fdout[2]; - int r; + ssize_t r; #ifdef BUILTIN_DECOMPRESS /* FIXME: This doesn't cope with bzip2 */ Index: src/external/bsd/file/dist/src/file.h diff -u src/external/bsd/file/dist/src/file.h:1.1.1.1 src/external/bsd/file/dist/src/file.h:1.2 --- src/external/bsd/file/dist/src/file.h:1.1.1.1 Fri May 8 12:35:06 2009 +++ src/external/bsd/file/dist/src/file.h Fri May 8 13:28:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: file.h,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $ */ +/* $NetBSD: file.h,v 1.2 2009/05/08 17:28:01 christos Exp $ */ /* * Copyright (c) Ian F. Darwin 1986-1995. @@ -300,7 +300,7 @@ #ifdef __cplusplus #define CAST(T, b) static_cast<T>(b) #else -#define CAST(T, b) (b) +#define CAST(T, b) (T)(b) #endif struct level_info { Index: src/external/bsd/file/dist/src/fsmagic.c diff -u src/external/bsd/file/dist/src/fsmagic.c:1.1.1.1 src/external/bsd/file/dist/src/fsmagic.c:1.2 --- src/external/bsd/file/dist/src/fsmagic.c:1.1.1.1 Fri May 8 12:35:06 2009 +++ src/external/bsd/file/dist/src/fsmagic.c Fri May 8 13:28:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: fsmagic.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $ */ +/* $NetBSD: fsmagic.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */ /* * Copyright (c) Ian F. Darwin 1986-1995. @@ -37,7 +37,7 @@ #if 0 FILE_RCSID("@(#)$File: fsmagic.c,v 1.59 2009/02/03 20:27:51 christos Exp $") #else -__RCSID("$NetBSD: fsmagic.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $"); +__RCSID("$NetBSD: fsmagic.c,v 1.2 2009/05/08 17:28:01 christos Exp $"); #endif #endif /* lint */ @@ -112,7 +112,7 @@ int mime = ms->flags & MAGIC_MIME; #ifdef S_IFLNK char buf[BUFSIZ+4]; - int nch; + ssize_t nch; struct stat tstatbuf; #endif Index: src/external/bsd/file/dist/src/funcs.c diff -u src/external/bsd/file/dist/src/funcs.c:1.1.1.1 src/external/bsd/file/dist/src/funcs.c:1.2 --- src/external/bsd/file/dist/src/funcs.c:1.1.1.1 Fri May 8 12:35:06 2009 +++ src/external/bsd/file/dist/src/funcs.c Fri May 8 13:28:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: funcs.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $ */ +/* $NetBSD: funcs.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */ /* * Copyright (c) Christos Zoulas 2003. @@ -32,7 +32,7 @@ #if 0 FILE_RCSID("@(#)$File: funcs.c,v 1.53 2009/04/07 11:07:00 christos Exp $") #else -__RCSID("$NetBSD: funcs.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $"); +__RCSID("$NetBSD: funcs.c,v 1.2 2009/05/08 17:28:01 christos Exp $"); #endif #endif /* lint */ @@ -101,7 +101,7 @@ /*VARARGS*/ private void file_error_core(struct magic_set *ms, int error, const char *f, va_list va, - uint32_t lineno) + size_t lineno) { /* Only the first error is ok */ if (ms->event_flags & EVENT_HAD_ERR) @@ -109,7 +109,7 @@ if (lineno != 0) { free(ms->o.buf); ms->o.buf = NULL; - file_printf(ms, "line %u: ", lineno); + file_printf(ms, "line %zu: ", lineno); } file_vprintf(ms, f, va); if (error > 0) Index: src/external/bsd/file/dist/src/magic.c diff -u src/external/bsd/file/dist/src/magic.c:1.1.1.1 src/external/bsd/file/dist/src/magic.c:1.2 --- src/external/bsd/file/dist/src/magic.c:1.1.1.1 Fri May 8 12:35:05 2009 +++ src/external/bsd/file/dist/src/magic.c Fri May 8 13:28:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: magic.c,v 1.1.1.1 2009/05/08 16:35:05 christos Exp $ */ +/* $NetBSD: magic.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */ /* * Copyright (c) Christos Zoulas 2003. @@ -33,7 +33,7 @@ #if 0 FILE_RCSID("@(#)$File: magic.c,v 1.62 2009/03/20 21:25:41 christos Exp $") #else -__RCSID("$NetBSD: magic.c,v 1.1.1.1 2009/05/08 16:35:05 christos Exp $"); +__RCSID("$NetBSD: magic.c,v 1.2 2009/05/08 17:28:01 christos Exp $"); #endif #endif /* lint */ @@ -94,7 +94,7 @@ struct magic_set *ms; size_t len; - if ((ms = CAST(magic_set *, calloc((size_t)1, + if ((ms = CAST(struct magic_set *, calloc((size_t)1, sizeof(struct magic_set)))) == NULL) return NULL; Index: src/external/bsd/file/dist/src/readcdf.c diff -u src/external/bsd/file/dist/src/readcdf.c:1.1.1.1 src/external/bsd/file/dist/src/readcdf.c:1.2 --- src/external/bsd/file/dist/src/readcdf.c:1.1.1.1 Fri May 8 12:35:06 2009 +++ src/external/bsd/file/dist/src/readcdf.c Fri May 8 13:28:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: readcdf.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $ */ +/* $NetBSD: readcdf.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */ /*- * Copyright (c) 2008 Christos Zoulas @@ -31,7 +31,7 @@ #if 0 FILE_RCSID("@(#)$File: readcdf.c,v 1.18 2009/05/06 20:48:22 christos Exp $") #else -__RCSID("$NetBSD: readcdf.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $"); +__RCSID("$NetBSD: readcdf.c,v 1.2 2009/05/08 17:28:01 christos Exp $"); #endif #endif @@ -166,20 +166,20 @@ switch (si.si_os) { case 2: if (file_printf(ms, ", Os: Windows, Version %d.%d", - si.si_os_version & 0xff, si.si_os_version >> 8) - == -1) + si.si_os_version & 0xff, + (uint32_t)si.si_os_version >> 8) == -1) return -1; break; case 1: if (file_printf(ms, ", Os: MacOS, Version %d.%d", - si.si_os_version >> 8, si.si_os_version & 0xff) - == -1) + (uint32_t)si.si_os_version >> 8, + si.si_os_version & 0xff) == -1) return -1; break; default: if (file_printf(ms, ", Os %d, Version: %d.%d", si.si_os, - si.si_os_version & 0xff, si.si_os_version >> 8) - == -1) + si.si_os_version & 0xff, + (uint32_t)si.si_os_version >> 8) == -1) return -1; break; } Index: src/external/bsd/file/dist/src/readelf.c diff -u src/external/bsd/file/dist/src/readelf.c:1.1.1.1 src/external/bsd/file/dist/src/readelf.c:1.2 --- src/external/bsd/file/dist/src/readelf.c:1.1.1.1 Fri May 8 12:35:06 2009 +++ src/external/bsd/file/dist/src/readelf.c Fri May 8 13:28:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: readelf.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $ */ +/* $NetBSD: readelf.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */ /* * Copyright (c) Christos Zoulas 2003. @@ -32,7 +32,7 @@ #if 0 FILE_RCSID("@(#)$File: readelf.c,v 1.81 2008/11/04 16:38:28 christos Exp $") #else -__RCSID("$NetBSD: readelf.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $"); +__RCSID("$NetBSD: readelf.c,v 1.2 2009/05/08 17:28:01 christos Exp $"); #endif #endif @@ -1025,7 +1025,7 @@ const char *linking_style = "statically"; const char *shared_libraries = ""; unsigned char nbuf[BUFSIZ]; - int bufsize; + ssize_t bufsize; size_t offset, align; off_t savedoffset = (off_t)-1; struct stat st; @@ -1080,7 +1080,7 @@ shared_libraries = " (uses shared libs)"; break; case PT_NOTE: - if ((align = xph_align) & 0x80000000) { + if ((align = xph_align) & 0x80000000UL) { if (file_printf(ms, ", invalid note alignment 0x%lx", (unsigned long)align) == -1) Index: src/external/bsd/file/dist/src/softmagic.c diff -u src/external/bsd/file/dist/src/softmagic.c:1.1.1.1 src/external/bsd/file/dist/src/softmagic.c:1.2 --- src/external/bsd/file/dist/src/softmagic.c:1.1.1.1 Fri May 8 12:35:06 2009 +++ src/external/bsd/file/dist/src/softmagic.c Fri May 8 13:28:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: softmagic.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $ */ +/* $NetBSD: softmagic.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */ /* * Copyright (c) Ian F. Darwin 1986-1995. @@ -37,7 +37,7 @@ #if 0 FILE_RCSID("@(#)$File: softmagic.c,v 1.135 2009/03/27 22:42:49 christos Exp $") #else -__RCSID("$NetBSD: softmagic.c,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $"); +__RCSID("$NetBSD: softmagic.c,v 1.2 2009/05/08 17:28:01 christos Exp $"); #endif #endif /* lint */ @@ -588,23 +588,23 @@ { switch (m->type) { case FILE_BYTE: - return ms->offset + sizeof(char); + return CAST(int32_t, (ms->offset + sizeof(char))); case FILE_SHORT: case FILE_BESHORT: case FILE_LESHORT: - return ms->offset + sizeof(short); + return CAST(int32_t, (ms->offset + sizeof(short))); case FILE_LONG: case FILE_BELONG: case FILE_LELONG: case FILE_MELONG: - return ms->offset + sizeof(int32_t); + return CAST(int32_t, (ms->offset + sizeof(int32_t))); case FILE_QUAD: case FILE_BEQUAD: case FILE_LEQUAD: - return ms->offset + sizeof(int64_t); + return CAST(int32_t, (ms->offset + sizeof(int64_t))); case FILE_STRING: case FILE_PSTRING: @@ -618,7 +618,7 @@ if (*m->value.s == '\0') p->s[strcspn(p->s, "\n")] = '\0'; - t = ms->offset + strlen(p->s); + t = CAST(uint32_t, (ms->offset + strlen(p->s))); if (m->type == FILE_PSTRING) t++; return t; @@ -628,46 +628,46 @@ case FILE_BEDATE: case FILE_LEDATE: case FILE_MEDATE: - return ms->offset + sizeof(time_t); + return CAST(int32_t, (ms->offset + sizeof(time_t))); case FILE_LDATE: case FILE_BELDATE: case FILE_LELDATE: case FILE_MELDATE: - return ms->offset + sizeof(time_t); + return CAST(int32_t, (ms->offset + sizeof(time_t))); case FILE_QDATE: case FILE_BEQDATE: case FILE_LEQDATE: - return ms->offset + sizeof(uint64_t); + return CAST(int32_t, (ms->offset + sizeof(uint64_t))); case FILE_QLDATE: case FILE_BEQLDATE: case FILE_LEQLDATE: - return ms->offset + sizeof(uint64_t); + return CAST(int32_t, (ms->offset + sizeof(uint64_t))); case FILE_FLOAT: case FILE_BEFLOAT: case FILE_LEFLOAT: - return ms->offset + sizeof(float); + return CAST(int32_t, (ms->offset + sizeof(float))); case FILE_DOUBLE: case FILE_BEDOUBLE: case FILE_LEDOUBLE: - return ms->offset + sizeof(double); - break; + return CAST(int32_t, (ms->offset + sizeof(double))); case FILE_REGEX: if ((m->str_flags & REGEX_OFFSET_START) != 0) - return ms->search.offset; + return CAST(int32_t, ms->search.offset); else - return ms->search.offset + ms->search.rm_len; + return CAST(int32_t, (ms->search.offset + + ms->search.rm_len)); case FILE_SEARCH: if ((m->str_flags & REGEX_OFFSET_START) != 0) - return ms->search.offset; + return CAST(int32_t, ms->search.offset); else - return ms->search.offset + m->vallen; + return CAST(int32_t, (ms->search.offset + m->vallen)); case FILE_DEFAULT: return ms->offset; @@ -930,7 +930,7 @@ if (indir == 0) { switch (type) { case FILE_SEARCH: - ms->search.s = (const char *)s + offset; + ms->search.s = CAST(const char *, s) + offset; ms->search.s_len = nbytes - offset; ms->search.offset = offset; return 0; @@ -948,18 +948,19 @@ ms->search.s = NULL; return 0; } - buf = (const char *)s + offset; - end = last = (const char *)s + nbytes; + buf = CAST(const char *, s) + offset; + end = last = CAST(const char *, s) + nbytes; /* mget() guarantees buf <= last */ - for (lines = linecnt, b = buf; - lines && ((b = memchr(c = b, '\n', end - b)) || (b = memchr(c, '\r', end - c))); + for (lines = linecnt, b = buf; lines && + ((b = memchr(c = b, '\n', CAST(size_t, (end - b)))) + || (b = memchr(c, '\r', CAST(size_t, (end - c))))); lines--, b++) { last = b; if (b[0] == '\r' && b[1] == '\n') b++; } if (lines) - last = (const char *)s + nbytes; + last = CAST(const char *, s) + nbytes; ms->search.s = buf; ms->search.s_len = last - buf; Added files: Index: src/external/bsd/file/Makefile.inc diff -u /dev/null src/external/bsd/file/Makefile.inc:1.1 --- /dev/null Fri May 8 13:28:02 2009 +++ src/external/bsd/file/Makefile.inc Fri May 8 13:28:01 2009 @@ -0,0 +1,17 @@ +# $NetBSD: Makefile.inc,v 1.1 2009/05/08 17:28:01 christos Exp $ + +DIST=${.CURDIR}/../dist + +USE_FORT?= yes # data-driven bugs? + +TOOL_MKMAGIC?= ${.OBJDIR}/file + +MFILESDIR?= /usr/share/misc +MFILES?= magic.mgc +MAGIC?= ${MFILESDIR}/magic + +CPPFLAGS+= -DMAGIC='"${MAGIC}"' -DHAVE_CONFIG_H -DQUICK -DBUILTIN_ELF \ + -DELFCORE +CPPFLAGS+= -I${.CURDIR}/../include -I${DIST}/src + +.PATH: ${DIST}/src ${DIST}/doc Index: src/external/bsd/file/bin/Makefile diff -u /dev/null src/external/bsd/file/bin/Makefile:1.1 --- /dev/null Fri May 8 13:28:02 2009 +++ src/external/bsd/file/bin/Makefile Fri May 8 13:28:01 2009 @@ -0,0 +1,33 @@ +# $NetBSD: Makefile,v 1.1 2009/05/08 17:28:01 christos Exp $ + +.include <bsd.own.mk> +.include <bsd.sys.mk> + +.include "../Makefile.inc" + +.if ${MKSHARE} != "no" +FILESDIR= ${MFILESDIR} +FILES= ${MFILES} +.endif + +PROG= file +LDADD+= -lmagic -lz +DPADD+= ${LIBMAGIC} ${LIBZ} +MAN= file.1 magic.5 + +CLEANFILES+= magic.mgc +.if ${MKSHARE} != "no" +realall: file magic.mgc +.endif + +.if ${MKSHARE} != "no" +magic.mgc: ${TOOL_MKMAGIC} + ${_MKTARGET_CREATE} + ${TOOL_MKMAGIC} -C -m ${DIST}/magic/magdir + @mv magdir.mgc ${.TARGET} + +.else +magic.mgc: +.endif + +.include <bsd.prog.mk> Index: src/external/bsd/file/include/config.h diff -u /dev/null src/external/bsd/file/include/config.h:1.1 --- /dev/null Fri May 8 13:28:02 2009 +++ src/external/bsd/file/include/config.h Fri May 8 13:28:02 2009 @@ -0,0 +1,270 @@ +/* $NetBSD: config.h,v 1.1 2009/05/08 17:28:02 christos Exp $ */ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define in built-in ELF support is used */ +#define BUILTIN_ELF 1 + +/* Define for ELF core file support */ +#define ELFCORE 1 + +/* Define to 1 if you have the `asprintf' function. */ +#define HAVE_ASPRINTF 1 + +/* HAVE_DAYLIGHT */ +#define HAVE_DAYLIGHT 1 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the <err.h> header file. */ +#define HAVE_ERR_H 1 + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the <getopt.h> header file. */ +#define HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getopt_long' function. */ +#define HAVE_GETOPT_LONG 1 + +/* Define to 1 if the system has the type `int32_t'. */ +#define HAVE_INT32_T 1 + +/* Define to 1 if the system has the type `int64_t'. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `z' library (-lz). */ +#define HAVE_LIBZ 1 + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if <wchar.h> declares mbstate_t. */ +#define HAVE_MBSTATE_T 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcat' function. */ +#define HAVE_STRLCAT 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the `strndup' function. */ +#define HAVE_STRNDUP 1 + +/* Define to 1 if you have the `strtof' function. */ +#define HAVE_STRTOF 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* HAVE_STRUCT_OPTION */ +#define HAVE_STRUCT_OPTION 1 + +/* Define to 1 if `st_rdev' is member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_gmtoff' is member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_GMTOFF 1 + +/* Define to 1 if `tm_zone' is member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if you have the <sys/mman.h> header file. */ +#define HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <sys/utime.h> header file. */ +/* #undef HAVE_SYS_UTIME_H */ + +/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* HAVE_TM_ISDST */ +#define HAVE_TM_ISDST 1 + +/* HAVE_TM_ZONE */ +#define HAVE_TM_ZONE 1 + +/* HAVE_TZNAME */ +#define HAVE_TZNAME 1 + +/* Define to 1 if the system has the type `uint16_t'. */ +#define HAVE_UINT16_T 1 + +/* Define to 1 if the system has the type `uint32_t'. */ +#define HAVE_UINT32_T 1 + +/* Define to 1 if the system has the type `uint64_t'. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uint8_t'. */ +#define HAVE_UINT8_T 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `utime' function. */ +#define HAVE_UTIME 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the <utime.h> header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `vasprintf' function. */ +#define HAVE_VASPRINTF 1 + +/* Define to 1 if you have the <wchar.h> header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the <wctype.h> header file. */ +#define HAVE_WCTYPE_H 1 + +/* Define to 1 if you have the `wcwidth' function. */ +#define HAVE_WCWIDTH 1 + +/* Define to 1 if you have the <zlib.h> header file. */ +#define HAVE_ZLIB_H 1 + +/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>. + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + <sysmacros.h>. */ +/* #undef MAJOR_IN_SYSMACROS */ + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Name of package */ +#define PACKAGE "file" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "chris...@astron.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "file" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "file 5.03" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "file" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "5.03" + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if your <sys/time.h> declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Version number of package */ +#define VERSION "5.03" + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +/* #undef _LARGEFILE_SOURCE */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to a type if <wchar.h> does not define. */ +/* #undef mbstate_t */ + +/* Define to `long int' if <sys/types.h> does not define. */ +/* #undef off_t */ + +/* Define to `unsigned int' if <sys/types.h> does not define. */ +/* #undef size_t */ + + +#ifndef HAVE_UINT8_T +typedef unsigned char uint8_t; +#endif +#ifndef HAVE_UINT16_T +typedef unsigned short uint16_t; +#endif +#ifndef HAVE_UINT32_T +typedef unsigned int uint32_t; +#endif +#ifndef HAVE_INT32_T +typedef int int32_t; +#endif +#ifndef HAVE_UINT64_T +#if SIZEOF_LONG_LONG == 8 +typedef unsigned long long uint64_t; +#else +typedef unsigned long uint64_t; +#endif +#endif +#ifndef HAVE_INT64_T +#if SIZEOF_LONG_LONG == 8 +typedef long long int64_t; +#else +typedef long int64_t; +#endif +#endif + Index: src/external/bsd/file/lib/Makefile diff -u /dev/null src/external/bsd/file/lib/Makefile:1.1 --- /dev/null Fri May 8 13:28:02 2009 +++ src/external/bsd/file/lib/Makefile Fri May 8 13:28:02 2009 @@ -0,0 +1,35 @@ +# $NetBSD: Makefile,v 1.1 2009/05/08 17:28:02 christos Exp $ +# + +USE_FORT?= yes # data driven bugs? + +.include <bsd.own.mk> + +.include "../Makefile.inc" + +LIB= magic +LIBDPLIBS+= z ${NETBSDSRCDIR}/lib/libz + +.if ${MACHINE_ARCH} == "i386" +# Set lint to exit on warnings +# XXX: Soon +#LINTFLAGS+= -w +.endif + +SRCS= magic.c apprentice.c softmagic.c ascmagic.c compress.c \ + is_tar.c readelf.c print.c fsmagic.c apptype.c funcs.c \ + cdf.c readcdf.c cdf_time.c encoding.c +MAN= libmagic.3 +MLINKS+= libmagic.3 magic_open.3 \ + libmagic.3 magic_close.3 \ + libmagic.3 magic_error.3 \ + libmagic.3 magic_file.3 \ + libmagic.3 magic_buffer.3 \ + libmagic.3 magic_setflags.3 \ + libmagic.3 magic_check.3 \ + libmagic.3 magic_compile.3 \ + libmagic.3 magic_load.3 +INCS= magic.h +INCSDIR= /usr/include + +.include <bsd.lib.mk> Index: src/external/bsd/file/lib/shlib_version diff -u /dev/null src/external/bsd/file/lib/shlib_version:1.1 --- /dev/null Fri May 8 13:28:02 2009 +++ src/external/bsd/file/lib/shlib_version Fri May 8 13:28:02 2009 @@ -0,0 +1,4 @@ +# $NetBSD: shlib_version,v 1.1 2009/05/08 17:28:02 christos Exp $ +# +major=3 +minor=0