[Midnightbsd-cvs] src [8767] trunk/usr.sbin/crunch: pull in some netbsd changes
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Sep 25 22:46:07 EDT 2016
Revision: 8767
http://svnweb.midnightbsd.org/src/?rev=8767
Author: laffer1
Date: 2016-09-25 22:46:07 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
pull in some netbsd changes
Modified Paths:
--------------
trunk/usr.sbin/crunch/crunchgen/crunched_main.c
trunk/usr.sbin/crunch/crunchgen/crunchgen.c
trunk/usr.sbin/crunch/crunchide/exec_elf32.c
trunk/usr.sbin/crunch/examples/really-big.conf
Modified: trunk/usr.sbin/crunch/crunchgen/crunched_main.c
===================================================================
--- trunk/usr.sbin/crunch/crunchgen/crunched_main.c 2016-09-26 02:45:08 UTC (rev 8766)
+++ trunk/usr.sbin/crunch/crunchgen/crunched_main.c 2016-09-26 02:46:07 UTC (rev 8767)
@@ -33,6 +33,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 +49,8 @@
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 +73,8 @@
}
-int crunched_here(char *path)
+int
+crunched_here(char *path)
{
char *slash, *basename;
struct stub *ep;
@@ -83,7 +89,8 @@
}
-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 +106,8 @@
}
-int crunched_usage()
+int
+crunched_usage()
{
int columns, len;
struct stub *ep;
@@ -122,4 +130,3 @@
}
/* end of crunched_main.c */
-
Modified: trunk/usr.sbin/crunch/crunchgen/crunchgen.c
===================================================================
--- trunk/usr.sbin/crunch/crunchgen/crunchgen.c 2016-09-26 02:45:08 UTC (rev 8766)
+++ trunk/usr.sbin/crunch/crunchgen/crunchgen.c 2016-09-26 02:46:07 UTC (rev 8767)
@@ -32,9 +32,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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
#include <sys/stat.h>
-#include <sys/param.h>
#include <ctype.h>
#include <err.h>
@@ -92,6 +95,7 @@
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 +107,24 @@
/* 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 +133,10 @@
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 +228,8 @@
}
-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 +248,7 @@
/* 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 +261,8 @@
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 +275,8 @@
}
-void parse_one_file(char *filename)
+void
+parse_one_file(char *filename)
{
char *fieldv[MAXFIELDS];
int fieldc;
@@ -329,15 +342,16 @@
}
-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 +360,7 @@
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 +374,8 @@
}
-void add_srcdirs(int argc, char **argv)
+void
+add_srcdirs(int argc, char **argv)
{
int i;
@@ -376,7 +391,8 @@
}
-void add_progs(int argc, char **argv)
+void
+add_progs(int argc, char **argv)
{
int i;
@@ -385,7 +401,8 @@
}
-void add_prog(char *progname)
+void
+add_prog(char *progname)
{
prog_t *p1, *p2;
@@ -426,7 +443,8 @@
}
-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 +465,8 @@
}
-void add_libs(int argc, char **argv)
+void
+add_libs(int argc, char **argv)
{
int i;
@@ -461,7 +480,8 @@
}
-void add_libs_so(int argc, char **argv)
+void
+add_libs_so(int argc, char **argv)
{
int i;
@@ -475,7 +495,8 @@
}
-void add_buildopts(int argc, char **argv)
+void
+add_buildopts(int argc, char **argv)
{
int i;
@@ -484,7 +505,8 @@
}
-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 +608,8 @@
char *dir_search(char *progname);
-void gen_outputs(void)
+void
+gen_outputs(void)
{
prog_t *p;
@@ -599,13 +622,15 @@
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 +705,8 @@
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,8 +746,8 @@
fprintf(f, "loop:\n\t at echo 'OBJS= '${%s}\n", objvar);
fprintf(f, "crunchgen_objs:\n"
- "\t at cd %s && make -f %s $(BUILDOPTS) $(%s_OPTS)",
- p->srcdir, tempfname, p->ident);
+ "\t at 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");
@@ -728,8 +754,8 @@
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 +770,17 @@
}
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 +793,8 @@
unlink(tempfname);
}
-void remove_error_progs(void)
+void
+remove_error_progs(void)
{
prog_t *p1, *p2;
@@ -788,7 +815,8 @@
}
}
-void gen_specials_cache(void)
+void
+gen_specials_cache(void)
{
FILE *cachef;
prog_t *p;
@@ -828,7 +856,8 @@
}
-void gen_output_makefile(void)
+void
+gen_output_makefile(void)
{
prog_t *p;
FILE *outmk;
@@ -858,9 +887,9 @@
}
-void gen_output_cfile(void)
+void
+gen_output_cfile(void)
{
- extern char *crunched_skel[];
char **cp;
FILE *outcf;
prog_t *p;
@@ -918,7 +947,7 @@
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 +975,8 @@
}
-void top_makefile_rules(FILE *outmk)
+void
+top_makefile_rules(FILE *outmk)
{
prog_t *p;
@@ -1004,7 +1034,8 @@
}
-void prog_makefile_rules(FILE *outmk, prog_t *p)
+void
+prog_makefile_rules(FILE *outmk, prog_t *p)
{
strlst_t *lst;
@@ -1089,7 +1120,8 @@
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 +1136,8 @@
*
*/
-void status(char *str)
+void
+status(const char *str)
{
static int lastlen = 0;
int len, spaces;
@@ -1123,13 +1156,15 @@
}
-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 +1188,8 @@
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 +1202,8 @@
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 +1212,8 @@
return 0;
}
-int is_dir(char *pathname)
+int
+is_dir(const char *pathname)
{
struct stat buf;
@@ -1185,7 +1223,8 @@
return S_ISDIR(buf.st_mode);
}
-int is_nonempty_file(char *pathname)
+int
+is_nonempty_file(const char *pathname)
{
struct stat buf;
Modified: trunk/usr.sbin/crunch/crunchide/exec_elf32.c
===================================================================
--- trunk/usr.sbin/crunch/crunchide/exec_elf32.c 2016-09-26 02:45:08 UTC (rev 8766)
+++ trunk/usr.sbin/crunch/crunchide/exec_elf32.c 2016-09-26 02:46:07 UTC (rev 8767)
@@ -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
__MBSDID("$MidnightBSD$");
@@ -98,7 +98,7 @@
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 @@
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 @@
*/
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 @@
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 @@
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 @@
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 @@
if (symtabp != NULL)
free(symtabp);
if (strtabp != NULL)
- free(strtabp);
+ free(nstrtabp);
return (rv);
bad:
Modified: trunk/usr.sbin/crunch/examples/really-big.conf
===================================================================
--- trunk/usr.sbin/crunch/examples/really-big.conf 2016-09-26 02:45:08 UTC (rev 8766)
+++ trunk/usr.sbin/crunch/examples/really-big.conf 2016-09-26 02:46:07 UTC (rev 8767)
@@ -72,7 +72,7 @@
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
More information about the Midnightbsd-cvs
mailing list