svn commit: r310579 - user/bapt/diff
Baptiste Daroussin
bapt at FreeBSD.org
Mon Dec 26 09:54:39 UTC 2016
Author: bapt
Date: Mon Dec 26 09:54:37 2016
New Revision: 310579
URL: https://svnweb.freebsd.org/changeset/base/310579
Log:
FreeBSDify ($FreeBSD) + fixes to build with base maximum set of warnings
Modified:
user/bapt/diff/Makefile
user/bapt/diff/diff.c
user/bapt/diff/diff.h
user/bapt/diff/diffdir.c
user/bapt/diff/diffreg.c
user/bapt/diff/xmalloc.c
user/bapt/diff/xmalloc.h
Modified: user/bapt/diff/Makefile
==============================================================================
--- user/bapt/diff/Makefile Mon Dec 26 09:52:19 2016 (r310578)
+++ user/bapt/diff/Makefile Mon Dec 26 09:54:37 2016 (r310579)
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.3 2007/05/29 18:24:56 ray Exp $
+# $FreEBSD$
PROG= diff
SRCS= diff.c diffdir.c diffreg.c xmalloc.c
-COPTS+= -Wall
+WARNS= 7
.include <bsd.prog.mk>
Modified: user/bapt/diff/diff.c
==============================================================================
--- user/bapt/diff/diff.c Mon Dec 26 09:52:19 2016 (r310578)
+++ user/bapt/diff/diff.c Mon Dec 26 09:54:37 2016 (r310579)
@@ -20,6 +20,9 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/stat.h>
#include <ctype.h>
@@ -72,7 +75,7 @@ static struct option longopts[] = {
{ NULL, 0, 0, '\0'}
};
-__dead void usage(void);
+void usage(void) __dead2;
void push_excludes(char *);
void push_ignore_pats(char *);
void read_excludes_file(char *file);
@@ -211,8 +214,10 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
+#ifdef __OpenBSD__
if (pledge("stdio rpath tmppath", NULL) == -1)
err(2, "pledge");
+#endif
/*
* Do sanity checks, fill in stb1 and stb2 and call the appropriate
@@ -349,7 +354,7 @@ print_only(const char *path, size_t dirl
}
void
-print_status(int val, char *path1, char *path2, char *entry)
+print_status(int val, char *path1, char *path2, const char *entry)
{
switch (val) {
case D_BINARY:
@@ -385,7 +390,7 @@ print_status(int val, char *path1, char
}
}
-__dead void
+void
usage(void)
{
(void)fprintf(stderr,
Modified: user/bapt/diff/diff.h
==============================================================================
--- user/bapt/diff/diff.h Mon Dec 26 09:52:19 2016 (r310578)
+++ user/bapt/diff/diff.h Mon Dec 26 09:54:37 2016 (r310579)
@@ -29,6 +29,7 @@
* SUCH DAMAGE.
*
* @(#)diff.h 8.1 (Berkeley) 6/6/93
+ * $FreeBSD$
*/
#include <sys/types.h>
@@ -95,4 +96,4 @@ void *emalloc(size_t);
void *erealloc(void *, size_t);
void diffdir(char *, char *, int);
void print_only(const char *, size_t, const char *);
-void print_status(int, char *, char *, char *);
+void print_status(int, char *, char *, const char *);
Modified: user/bapt/diff/diffdir.c
==============================================================================
--- user/bapt/diff/diffdir.c Mon Dec 26 09:52:19 2016 (r310578)
+++ user/bapt/diff/diffdir.c Mon Dec 26 09:54:37 2016 (r310579)
@@ -20,6 +20,9 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/stat.h>
#include <dirent.h>
Modified: user/bapt/diff/diffreg.c
==============================================================================
--- user/bapt/diff/diffreg.c Mon Dec 26 09:52:19 2016 (r310578)
+++ user/bapt/diff/diffreg.c Mon Dec 26 09:54:37 2016 (r310579)
@@ -64,6 +64,9 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/stat.h>
#include <sys/wait.h>
@@ -159,7 +162,7 @@ struct cand {
int pred;
};
-struct line {
+static struct line {
int serial;
int value;
} *file[2];
@@ -180,7 +183,7 @@ struct context_vec {
static FILE *opentemp(const char *);
static void output(char *, FILE *, char *, FILE *, int);
static void check(FILE *, FILE *, int);
-static void range(int, int, char *);
+static void range(int, int, const char *);
static void uni_range(int, int);
static void dump_context_vec(FILE *, FILE *, int);
static void dump_unified_vec(FILE *, FILE *, int);
@@ -235,7 +238,7 @@ static int lastmatchline;
* chrtran points to one of 2 translation tables: cup2low if folding upper to
* lower case clow2low if not folding case
*/
-u_char clow2low[256] = {
+static u_char clow2low[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
@@ -262,7 +265,7 @@ u_char clow2low[256] = {
0xfd, 0xfe, 0xff
};
-u_char cup2low[256] = {
+static u_char cup2low[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
@@ -444,15 +447,15 @@ files_differ(FILE *f1, FILE *f2, int fla
}
static FILE *
-opentemp(const char *file)
+opentemp(const char *path)
{
char buf[BUFSIZ], tempfile[PATH_MAX];
ssize_t nread;
int ifd, ofd;
- if (strcmp(file, "-") == 0)
+ if (strcmp(path, "-") == 0)
ifd = STDIN_FILENO;
- else if ((ifd = open(file, O_RDONLY, 0644)) < 0)
+ else if ((ifd = open(path, O_RDONLY, 0644)) < 0)
return (NULL);
(void)strlcpy(tempfile, _PATH_TMP "/diff.XXXXXXXX", sizeof(tempfile));
@@ -475,7 +478,7 @@ opentemp(const char *file)
}
char *
-splice(char *dir, char *file)
+splice(char *dir, char *path)
{
char *tail, *buf;
size_t dirlen;
@@ -483,8 +486,8 @@ splice(char *dir, char *file)
dirlen = strlen(dir);
while (dirlen != 0 && dir[dirlen - 1] == '/')
dirlen--;
- if ((tail = strrchr(file, '/')) == NULL)
- tail = file;
+ if ((tail = strrchr(path, '/')) == NULL)
+ tail = path;
else
tail++;
xasprintf(&buf, "%.*s/%s", (int)dirlen, dir, tail);
@@ -495,12 +498,12 @@ static void
prepare(int i, FILE *fd, off_t filesize, int flags)
{
struct line *p;
- int j, h;
- size_t sz;
+ int h;
+ size_t sz, j;
rewind(fd);
- sz = (filesize <= SIZE_MAX ? filesize : SIZE_MAX) / 25;
+ sz = ((unsigned long)filesize <= SIZE_MAX ? filesize : SIZE_MAX) / 25;
if (sz < 100)
sz = 100;
@@ -905,7 +908,7 @@ output(char *file1, FILE *f1, char *file
}
static void
-range(int a, int b, char *separator)
+range(int a, int b, const char *separator)
{
diff_output("%d", a > b ? b : a);
if (a < b)
@@ -1253,7 +1256,7 @@ match_function(const long *f, int pos, F
unsigned char buf[FUNCTION_CONTEXT_SIZE];
size_t nc;
int last = lastline;
- char *state = NULL;
+ const char *state = NULL;
lastline = pos;
while (pos > last) {
Modified: user/bapt/diff/xmalloc.c
==============================================================================
--- user/bapt/diff/xmalloc.c Mon Dec 26 09:52:19 2016 (r310578)
+++ user/bapt/diff/xmalloc.c Mon Dec 26 09:54:37 2016 (r310579)
@@ -13,6 +13,9 @@
* called by a name other than "ssh" or "Secure Shell".
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <err.h>
#include <stdarg.h>
#include <stdint.h>
Modified: user/bapt/diff/xmalloc.h
==============================================================================
--- user/bapt/diff/xmalloc.h Mon Dec 26 09:52:19 2016 (r310578)
+++ user/bapt/diff/xmalloc.h Mon Dec 26 09:54:37 2016 (r310579)
@@ -14,6 +14,8 @@
* software must be clearly marked as such, and if the derived work is
* incompatible with the protocol description in the RFC file, it must be
* called by a name other than "ssh" or "Secure Shell".
+ *
+ * $FreeBSD$
*/
#ifndef XMALLOC_H
More information about the svn-src-user
mailing list