commit 5309f0eef06dc0d7e3ee0d3904693d5fac9e91f9
parent 9a0e9d213b244658a182d7c076d71059a8253f70
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Tue, 8 Jan 2019 11:31:21 +0000
Fix several warnings
Diffstat:
5 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/include/scc/scc/mach.h b/include/scc/scc/mach.h
@@ -45,18 +45,18 @@ extern int artraverse(FILE *fp,
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);
diff --git 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>
diff --git 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 @@ new(Obj *obj)
return 0;
}
-static void
+static int
strip(Obj *obj)
{
struct coff32 *coff = obj->data;
diff --git a/src/libmach/libmach.h b/src/libmach/libmach.h
@@ -33,10 +33,10 @@ struct format {
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, ...);
diff --git a/src/libmach/object.c b/src/libmach/object.c
@@ -159,24 +159,26 @@ delsyms(Obj *obj)
memset(obj->htab, 0, sizeof(obj->htab));
}
-void
+int
objreset(Obj *obj)
{
int fmt;
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 @@ objstrip(Obj *obj)
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 @@ objsize(Obj *obj,
return -1;
op = objfmt[fmt];
(*op->size)(obj, text, data, bss);
+ return 0;
}