shithub: scc

Download patch

ref: d0a9d4f58eb08bf3d1ffff3ce0da5b9d9f4b497a
parent: 015d343c41900f127914b3f0345353c9b0deff77
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Jan 8 06:31:21 EST 2019

Fix several warnings

--- a/include/scc/scc/mach.h
+++ b/include/scc/scc/mach.h
@@ -45,18 +45,18 @@
 
 extern int objtype(FILE *fp, char **name);
 extern Obj *objnew(int type);
-extern void objdel(Obj *obj);
-extern void objreset(Obj *obj);
+extern int objdel(Obj *obj);
+extern int objreset(Obj *obj);
 extern int objread(Obj *obj, FILE *fp);
 extern Symbol *objlookup(Obj *obj, char *name);
 extern int objtraverse(Obj *obj, int (*fn)(Symbol *sym, void *data), void *data);
-extern void objstrip(Obj *obj);
+extern int objstrip(Obj *obj);
 
 /* TODO */
 extern int objload(Obj *obj, Obj *to);
 extern int objreloc(Obj *obj, char *sect, void *rel);
 extern int objwrite(Obj *obj, FILE *fp);
-extern void objsize(Obj *obj,
-                    unsigned long long *text,
-                    unsigned long long *data,
-                    unsigned long long *bss);
+extern int objsize(Obj *obj,
+                   unsigned long long *text,
+                   unsigned long long *data,
+                   unsigned long long *bss);
--- a/src/as/target/x86/ins.c
+++ b/src/as/target/x86/ins.c
@@ -1,6 +1,7 @@
 static char sccsid[] = "@(#) ./as/target/x86/ins.c";
 
 #include <stdlib.h>
+#include <string.h>
 
 #include <scc/scc.h>
 
--- a/src/libmach/coff32.c
+++ b/src/libmach/coff32.c
@@ -3,6 +3,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <scc/coff32/filehdr.h>
 #include <scc/coff32/scnhdr.h>
@@ -360,7 +361,7 @@
 	return 0;
 }
 
-static void
+static int
 strip(Obj *obj)
 {
 	struct coff32 *coff = obj->data;
--- a/src/libmach/libmach.h
+++ b/src/libmach/libmach.h
@@ -33,10 +33,10 @@
 	int (*read)(Obj *obj, FILE *fp);
 	int (*write)(Obj *obj, FILE *fp);
 	void (*del)(Obj *obj);
-	int (*size)(Obj *obj,
-                unsigned long long *,
-                unsigned long long *,
-                unsigned long long *)
+	void (*size)(Obj *obj,
+                 unsigned long long *,
+                 unsigned long long *,
+                 unsigned long long *);
 };
 
 extern int pack(int order, unsigned char *dst, char *fmt, ...);
--- a/src/libmach/object.c
+++ b/src/libmach/object.c
@@ -159,7 +159,7 @@
 	memset(obj->htab, 0, sizeof(obj->htab));
 }
 
-void
+int
 objreset(Obj *obj)
 {
 	int fmt;
@@ -166,17 +166,19 @@
 	struct format *op;
 
 	fmt = FORMAT(obj->type);
-	if (fmt < NFORMATS) {
-		op = objfmt[fmt];
-		(*op->del)(obj);
-	}
+	if (fmt < NFORMATS)
+		return -1;
+	op = objfmt[fmt];
+	(*op->del)(obj);
 	delsyms(obj);
+	return 0;
 }
 
-void
+int
 objdel(Obj *obj)
 {
-	objreset(obj);
+	if (objreset(obj) < 0)
+		return -1;
 	free(obj);
 }
 
@@ -192,9 +194,10 @@
 	op = objfmt[fmt];
 	(*op->strip)(obj);
 	delsyms(obj);
+	return 0;
 }
 
-void
+int
 objsize(Obj *obj,
         unsigned long long *text,
         unsigned long long *data,
@@ -208,4 +211,5 @@
 		return -1;
 	op = objfmt[fmt];
 	(*op->size)(obj, text, data, bss);
+	return 0;
 }