Date: Sat, 9 Feb 2013 01:08:50 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r246576 - in stable/9/usr.sbin/crunch: crunchgen crunchide examples Message-ID: <201302090108.r1918okl014615@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Sat Feb 9 01:08:49 2013 New Revision: 246576 URL: http://svnweb.freebsd.org/changeset/base/246576 Log: MFC r237574, r237625, r246256; crunch: Sync some NetBSD changes. crunchide: Apr 11, 2009: fix some -Wsign-compare issues. Sep 20, 1999: Free the right thing. crunchgen: Apr 14, 2009: Fix some WARNS=4 issues (-Wshadow -Wcast-qual) Oct 30, 2004: Add (unsigned char) cast to ctype functions Feb 5, 2001: fix nested extern. examples: Aug 30, 2007: NetBSD 36867 - trsp references are deprecated In order to merge this I also had to merge some previous changes: - Ensure crunchen uses the same make binary as the rest of the build. - Some amount of style(9): function definitions, header ordering, and $FreeBSD$. Modified: stable/9/usr.sbin/crunch/crunchgen/crunched_main.c stable/9/usr.sbin/crunch/crunchgen/crunchgen.c stable/9/usr.sbin/crunch/crunchide/crunchide.c stable/9/usr.sbin/crunch/crunchide/exec_elf32.c stable/9/usr.sbin/crunch/examples/really-big.conf Directory Properties: stable/9/usr.sbin/crunch/ (props changed) Modified: stable/9/usr.sbin/crunch/crunchgen/crunched_main.c ============================================================================== --- stable/9/usr.sbin/crunch/crunchgen/crunched_main.c Sat Feb 9 00:35:28 2013 (r246575) +++ stable/9/usr.sbin/crunch/crunchgen/crunched_main.c Sat Feb 9 01:08:49 2013 (r246576) @@ -22,8 +22,6 @@ * Author: James da Silva, Systems Design and Analysis Group * Computer Science Department * University of Maryland at College Park - * - * $FreeBSD$ */ /* * crunched_main.c - main program for crunched binaries, it branches to a @@ -33,6 +31,10 @@ * or calls one of them based on argv[1]. This allows the testing of * the crunched binary without creating all the links. */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -45,7 +47,8 @@ struct stub { extern char *__progname; extern struct stub entry_points[]; -int main(int argc, char **argv, char **envp) +int +main(int argc, char **argv, char **envp) { char *slash, *basename; struct stub *ep; @@ -68,7 +71,8 @@ int main(int argc, char **argv, char **e } -int crunched_here(char *path) +int +crunched_here(char *path) { char *slash, *basename; struct stub *ep; @@ -83,7 +87,8 @@ int crunched_here(char *path) } -int crunched_main(int argc, char **argv, char **envp) +int +crunched_main(int argc, char **argv, char **envp) { char *slash; struct stub *ep; @@ -99,7 +104,8 @@ int crunched_main(int argc, char **argv, } -int crunched_usage() +int +crunched_usage() { int columns, len; struct stub *ep; @@ -122,4 +128,3 @@ int crunched_usage() } /* end of crunched_main.c */ - Modified: stable/9/usr.sbin/crunch/crunchgen/crunchgen.c ============================================================================== --- stable/9/usr.sbin/crunch/crunchgen/crunchgen.c Sat Feb 9 00:35:28 2013 (r246575) +++ stable/9/usr.sbin/crunch/crunchgen/crunchgen.c Sat Feb 9 01:08:49 2013 (r246576) @@ -22,8 +22,6 @@ * Author: James da Silva, Systems Design and Analysis Group * Computer Science Department * University of Maryland at College Park - * - * $FreeBSD$ */ /* * ======================================================================== @@ -32,9 +30,12 @@ * Generates a Makefile and main C file for a crunched executable, * from specs given in a .conf file. */ -#include <sys/types.h> -#include <sys/stat.h> + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <sys/param.h> +#include <sys/stat.h> #include <ctype.h> #include <err.h> @@ -92,6 +93,7 @@ char outmkname[MAXPATHLEN], outcfname[MA char tempfname[MAXPATHLEN], cachename[MAXPATHLEN], curfilename[MAXPATHLEN]; char outhdrname[MAXPATHLEN] ; /* user-supplied header for *.mk */ char *objprefix; /* where are the objects ? */ +char *path_make; int linenum = -1; int goterror = 0; @@ -103,22 +105,24 @@ int list_mode; /* general library routines */ -void status(char *str); +void status(const char *str); void out_of_memory(void); void add_string(strlst_t **listp, char *str); -int is_dir(char *pathname); -int is_nonempty_file(char *pathname); +int is_dir(const char *pathname); +int is_nonempty_file(const char *pathname); int subtract_strlst(strlst_t **lista, strlst_t **listb); int in_list(strlst_t **listp, char *str); -/* helper routines for main() */ + +extern char *crunched_skel[]; void usage(void); void parse_conf_file(void); void gen_outputs(void); -int main(int argc, char **argv) +int +main(int argc, char **argv) { char *p; int optc; @@ -127,6 +131,10 @@ int main(int argc, char **argv) readcache = 1; *outmkname = *outcfname = *execfname = '\0'; + path_make = getenv("MAKE"); + if (path_make == NULL || *path_make == '\0') + path_make = "make"; + p = getenv("MAKEOBJDIRPREFIX"); if (p == NULL || *p == '\0') objprefix = "/usr/obj"; /* default */ @@ -218,7 +226,8 @@ int main(int argc, char **argv) } -void usage(void) +void +usage(void) { fprintf(stderr, "%s%s\n\t%s%s\n", "usage: crunchgen [-foq] ", "[-h <makefile-header-name>] [-m <makefile>]", @@ -237,7 +246,7 @@ void usage(void) /* helper routines for parse_conf_file */ void parse_one_file(char *filename); -void parse_line(char *line, int *fc, char **fv, int nf); +void parse_line(char *pline, int *fc, char **fv, int nf); void add_srcdirs(int argc, char **argv); void add_progs(int argc, char **argv); void add_link(int argc, char **argv); @@ -250,7 +259,8 @@ prog_t *find_prog(char *str); void add_prog(char *progname); -void parse_conf_file(void) +void +parse_conf_file(void) { if (!is_nonempty_file(infilename)) errx(1, "fatal: input file \"%s\" not found", infilename); @@ -263,7 +273,8 @@ void parse_conf_file(void) } -void parse_one_file(char *filename) +void +parse_one_file(char *filename) { char *fieldv[MAXFIELDS]; int fieldc; @@ -329,15 +340,16 @@ void parse_one_file(char *filename) } -void parse_line(char *line, int *fc, char **fv, int nf) +void +parse_line(char *pline, int *fc, char **fv, int nf) { char *p; - p = line; + p = pline; *fc = 0; while (1) { - while (isspace(*p)) + while (isspace((unsigned char)*p)) p++; if (*p == '\0' || *p == '#') @@ -346,7 +358,7 @@ void parse_line(char *line, int *fc, cha if (*fc < nf) fv[(*fc)++] = p; - while (*p && !isspace(*p) && *p != '#') + while (*p && !isspace((unsigned char)*p) && *p != '#') p++; if (*p == '\0' || *p == '#') @@ -360,7 +372,8 @@ void parse_line(char *line, int *fc, cha } -void add_srcdirs(int argc, char **argv) +void +add_srcdirs(int argc, char **argv) { int i; @@ -376,7 +389,8 @@ void add_srcdirs(int argc, char **argv) } -void add_progs(int argc, char **argv) +void +add_progs(int argc, char **argv) { int i; @@ -385,7 +399,8 @@ void add_progs(int argc, char **argv) } -void add_prog(char *progname) +void +add_prog(char *progname) { prog_t *p1, *p2; @@ -426,7 +441,8 @@ void add_prog(char *progname) } -void add_link(int argc, char **argv) +void +add_link(int argc, char **argv) { int i; prog_t *p = find_prog(argv[1]); @@ -447,7 +463,8 @@ void add_link(int argc, char **argv) } -void add_libs(int argc, char **argv) +void +add_libs(int argc, char **argv) { int i; @@ -461,7 +478,8 @@ void add_libs(int argc, char **argv) } -void add_libs_so(int argc, char **argv) +void +add_libs_so(int argc, char **argv) { int i; @@ -475,7 +493,8 @@ void add_libs_so(int argc, char **argv) } -void add_buildopts(int argc, char **argv) +void +add_buildopts(int argc, char **argv) { int i; @@ -484,7 +503,8 @@ void add_buildopts(int argc, char **argv } -void add_special(int argc, char **argv) +void +add_special(int argc, char **argv) { int i; prog_t *p = find_prog(argv[1]); @@ -586,7 +606,8 @@ char *genident(char *str); char *dir_search(char *progname); -void gen_outputs(void) +void +gen_outputs(void) { prog_t *p; @@ -599,13 +620,15 @@ void gen_outputs(void) gen_output_makefile(); status(""); fprintf(stderr, - "Run \"make -f %s\" to build crunched binary.\n", outmkname); + "Run \"%s -f %s\" to build crunched binary.\n", + path_make, outmkname); } /* * run the makefile for the program to find which objects are necessary */ -void fillin_program(prog_t *p) +void +fillin_program(prog_t *p) { char path[MAXPATHLEN]; char line[MAXLINELEN]; @@ -680,7 +703,8 @@ void fillin_program(prog_t *p) p->goterror = 1; } -void fillin_program_objs(prog_t *p, char *path) +void +fillin_program_objs(prog_t *p, char *path) { char *obj, *cp; int fd, rc; @@ -720,16 +744,16 @@ void fillin_program_objs(prog_t *p, char fprintf(f, "loop:\n\t@echo 'OBJS= '${%s}\n", objvar); fprintf(f, "crunchgen_objs:\n" - "\t@cd %s && make -f %s $(BUILDOPTS) $(%s_OPTS)", - p->srcdir, tempfname, p->ident); + "\t@cd %s && %s -f %s $(BUILDOPTS) $(%s_OPTS)", + p->srcdir, path_make, tempfname, p->ident); for (s = p->buildopts; s != NULL; s = s->next) fprintf(f, " %s", s->str); fprintf(f, " loop\n"); fclose(f); - snprintf(line, MAXLINELEN, "cd %s && make -f %s -B crunchgen_objs", - p->srcdir, tempfname); + snprintf(line, MAXLINELEN, "cd %s && %s -f %s -B crunchgen_objs", + p->srcdir, path_make, tempfname); if ((f = popen(line, "r")) == NULL) { warn("submake pipe"); goterror = 1; @@ -744,17 +768,17 @@ void fillin_program_objs(prog_t *p, char } cp = line + 6; - while (isspace(*cp)) + while (isspace((unsigned char)*cp)) cp++; while(*cp) { obj = cp; - while (*cp && !isspace(*cp)) + while (*cp && !isspace((unsigned char)*cp)) cp++; if (*cp) *cp++ = '\0'; add_string(&p->objs, obj); - while (isspace(*cp)) + while (isspace((unsigned char)*cp)) cp++; } } @@ -767,7 +791,8 @@ void fillin_program_objs(prog_t *p, char unlink(tempfname); } -void remove_error_progs(void) +void +remove_error_progs(void) { prog_t *p1, *p2; @@ -788,7 +813,8 @@ void remove_error_progs(void) } } -void gen_specials_cache(void) +void +gen_specials_cache(void) { FILE *cachef; prog_t *p; @@ -828,7 +854,8 @@ void gen_specials_cache(void) } -void gen_output_makefile(void) +void +gen_output_makefile(void) { prog_t *p; FILE *outmk; @@ -858,9 +885,9 @@ void gen_output_makefile(void) } -void gen_output_cfile(void) +void +gen_output_cfile(void) { - extern char *crunched_skel[]; char **cp; FILE *outcf; prog_t *p; @@ -918,7 +945,7 @@ char *genident(char *str) for (d = s = n; *s != '\0'; s++) { if (*s == '-') *d++ = '_'; - else if (*s == '_' || isalnum(*s)) + else if (*s == '_' || isalnum((unsigned char)*s)) *d++ = *s; } *d = '\0'; @@ -946,7 +973,8 @@ char *dir_search(char *progname) } -void top_makefile_rules(FILE *outmk) +void +top_makefile_rules(FILE *outmk) { prog_t *p; @@ -1004,7 +1032,8 @@ void top_makefile_rules(FILE *outmk) } -void prog_makefile_rules(FILE *outmk, prog_t *p) +void +prog_makefile_rules(FILE *outmk, prog_t *p) { strlst_t *lst; @@ -1089,7 +1118,8 @@ void prog_makefile_rules(FILE *outmk, pr fprintf(outmk, "%s.lo\n", p->name); } -void output_strlst(FILE *outf, strlst_t *lst) +void +output_strlst(FILE *outf, strlst_t *lst) { for (; lst != NULL; lst = lst->next) if ( strlen(lst->str) ) @@ -1104,7 +1134,8 @@ void output_strlst(FILE *outf, strlst_t * */ -void status(char *str) +void +status(const char *str) { static int lastlen = 0; int len, spaces; @@ -1123,13 +1154,15 @@ void status(char *str) } -void out_of_memory(void) +void +out_of_memory(void) { err(1, "%s: %d: out of memory, stopping", infilename, linenum); } -void add_string(strlst_t **listp, char *str) +void +add_string(strlst_t **listp, char *str) { strlst_t *p1, *p2; @@ -1153,7 +1186,8 @@ void add_string(strlst_t **listp, char * p1->next = p2; } -int subtract_strlst(strlst_t **lista, strlst_t **listb) +int +subtract_strlst(strlst_t **lista, strlst_t **listb) { int subtract_count = 0; strlst_t *p1; @@ -1166,7 +1200,8 @@ int subtract_strlst(strlst_t **lista, st return subtract_count; } -int in_list(strlst_t **listp, char *str) +int +in_list(strlst_t **listp, char *str) { strlst_t *p1; for (p1 = *listp; p1 != NULL; p1 = p1->next) @@ -1175,7 +1210,8 @@ int in_list(strlst_t **listp, char *str) return 0; } -int is_dir(char *pathname) +int +is_dir(const char *pathname) { struct stat buf; @@ -1185,7 +1221,8 @@ int is_dir(char *pathname) return S_ISDIR(buf.st_mode); } -int is_nonempty_file(char *pathname) +int +is_nonempty_file(const char *pathname) { struct stat buf; Modified: stable/9/usr.sbin/crunch/crunchide/crunchide.c ============================================================================== --- stable/9/usr.sbin/crunch/crunchide/crunchide.c Sat Feb 9 00:35:28 2013 (r246575) +++ stable/9/usr.sbin/crunch/crunchide/crunchide.c Sat Feb 9 01:08:49 2013 (r246576) @@ -1,5 +1,4 @@ /* $NetBSD: crunchide.c,v 1.8 1997/11/01 06:51:45 lukem Exp $ */ -/* $FreeBSD$ */ /* * Copyright (c) 1997 Christopher G. Demetriou. All rights reserved. * Copyright (c) 1994 University of Maryland @@ -59,20 +58,22 @@ * that the final crunched binary BSS size is the max of all the * component programs' BSS sizes, rather than their sum. */ + #include <sys/cdefs.h> #ifndef lint __RCSID("$NetBSD: crunchide.c,v 1.8 1997/11/01 06:51:45 lukem Exp $"); #endif +__FBSDID("$FreeBSD$"); +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/errno.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <a.out.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/errno.h> #include "extern.h" @@ -89,9 +90,8 @@ int verbose; int main(int, char *[]); -int main(argc, argv) -int argc; -char **argv; +int +main(int argc, char **argv) { int ch, errors; @@ -127,7 +127,8 @@ char **argv; return errors; } -void usage(void) +void +usage(void) { fprintf(stderr, "usage: %s [-k <symbol-name>] [-f <keep-list-file>] <files> ...\n", @@ -142,7 +143,8 @@ struct keep { char *sym; } *keep_list; -void add_to_keep_list(char *symbol) +void +add_to_keep_list(char *symbol) { struct keep *newp, *prevp, *curp; int cmp; @@ -167,7 +169,8 @@ void add_to_keep_list(char *symbol) else keep_list = newp; } -int in_keep_list(const char *symbol) +int +in_keep_list(const char *symbol) { struct keep *curp; int cmp; @@ -180,7 +183,8 @@ int in_keep_list(const char *symbol) return curp && cmp == 0; } -void add_file_to_keep_list(char *filename) +void +add_file_to_keep_list(char *filename) { FILE *keepf; char symbol[1024]; @@ -222,7 +226,8 @@ struct { #endif }; -int hide_syms(const char *filename) +int +hide_syms(const char *filename) { int fd, i, n, rv; Modified: stable/9/usr.sbin/crunch/crunchide/exec_elf32.c ============================================================================== --- stable/9/usr.sbin/crunch/crunchide/exec_elf32.c Sat Feb 9 00:35:28 2013 (r246575) +++ stable/9/usr.sbin/crunch/crunchide/exec_elf32.c Sat Feb 9 01:08:49 2013 (r246576) @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint #if 0 -__RCSID("$NetBSD: exec_elf32.c,v 1.4 1997/08/12 06:07:24 mikel Exp $"); +__RCSID("$NetBSD: exec_elf32.c,v 1.6 1999/09/20 04:12:16 christos Exp $"); #endif #endif __FBSDID("$FreeBSD$"); @@ -98,7 +98,7 @@ xreadatoff(int fd, void *buf, off_t off, perror(fn); return -1; } - if ((rv = read(fd, buf, size)) != size) { + if ((size_t)(rv = read(fd, buf, size)) != size) { fprintf(stderr, "%s: read error: %s\n", fn, rv == -1 ? strerror(errno) : "short read"); return -1; @@ -115,7 +115,7 @@ xwriteatoff(int fd, void *buf, off_t off perror(fn); return -1; } - if ((rv = write(fd, buf, size)) != size) { + if ((size_t)(rv = write(fd, buf, size)) != size) { fprintf(stderr, "%s: write error: %s\n", fn, rv == -1 ? strerror(errno) : "short write"); return -1; @@ -162,7 +162,7 @@ ELFNAMEEND(check)(int fd, const char *fn */ if (fstat(fd, &sb) == -1) return 0; - if (sb.st_size < sizeof eh) + if (sb.st_size < (off_t)(sizeof eh)) return 0; if (read(fd, &eh, sizeof eh) != sizeof eh) return 0; @@ -305,7 +305,7 @@ ELFNAMEEND(hide)(int fd, const char *fn) if ((symtabp = xmalloc(xewtoh(symtabshdr->sh_size), fn, "symbol table")) == NULL) goto bad; - if (xreadatoff(fd, symtabp, xewtoh(symtabshdr->sh_offset), + if ((size_t)xreadatoff(fd, symtabp, xewtoh(symtabshdr->sh_offset), xewtoh(symtabshdr->sh_size), fn) != xewtoh(symtabshdr->sh_size)) goto bad; @@ -313,7 +313,7 @@ ELFNAMEEND(hide)(int fd, const char *fn) if ((strtabp = xmalloc(xewtoh(strtabshdr->sh_size), fn, "string table")) == NULL) goto bad; - if (xreadatoff(fd, strtabp, xewtoh(strtabshdr->sh_offset), + if ((size_t)xreadatoff(fd, strtabp, xewtoh(strtabshdr->sh_offset), xewtoh(strtabshdr->sh_size), fn) != xewtoh(strtabshdr->sh_size)) goto bad; @@ -370,7 +370,7 @@ ELFNAMEEND(hide)(int fd, const char *fn) if (xwriteatoff(fd, shdrp, xewtoh(ehdr.e_shoff), shdrsize, fn) != shdrsize) goto bad; - if (xwriteatoff(fd, symtabp, xewtoh(symtabshdr->sh_offset), + if ((size_t)xwriteatoff(fd, symtabp, xewtoh(symtabshdr->sh_offset), xewtoh(symtabshdr->sh_size), fn) != xewtoh(symtabshdr->sh_size)) goto bad; /* write new symbol table strings */ @@ -384,7 +384,7 @@ out: if (symtabp != NULL) free(symtabp); if (strtabp != NULL) - free(strtabp); + free(nstrtabp); return (rv); bad: Modified: stable/9/usr.sbin/crunch/examples/really-big.conf ============================================================================== --- stable/9/usr.sbin/crunch/examples/really-big.conf Sat Feb 9 00:35:28 2013 (r246575) +++ stable/9/usr.sbin/crunch/examples/really-big.conf Sat Feb 9 01:08:49 2013 (r246576) @@ -72,7 +72,7 @@ progs dev_mkdb diskpart edquota flcopy g progs iostat iteconfig kvm_mkdb mtree named portmap pppd progs pstat pwd_mkdb quot quotaon rarpd rbootd repquota rmt rpc.bootparamd progs rwhod sa spray sysctl syslogd tcpdump -progs traceroute trpt trsp update vipw vnconfig ypbind yppoll ypset +progs traceroute trpt update vipw vnconfig ypbind yppoll ypset special amd srcdir /usr/src/usr.sbin/amd/amd special amd objs vers.amd.o afs_ops.o am_ops.o clock.o util.o xutil.o efs_ops.o mapc.o info_file.o info_hes.o info_ndbm.o info_passwd.o info_nis.o info_union.o map.o srvr_afs.o srvr_nfs.o mntfs.o misc_rpc.o mount_fs.o mtab.o mtab_bsd.o nfs_ops.o nfs_prot_svc.o nfs_start.o nfs_subr.o opts.o pfs_ops.o rpc_fwd.o sched.o sfs_ops.o amq_svc.o amq_subr.o umount_fs.o host_ops.o nfsx_ops.o ufs_ops.o ifs_ops.o amd.o get_args.o restart.o wire.o
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302090108.r1918okl014615>