From dd1ee5f40f185d45141f04644505cb56dc101533 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 4 Jan 2015 21:34:11 +0000 Subject: make usage of strlcpy on linux possible throug usage of libbsd --- Makefile | 2 +- symbols.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e8a953f..72a208d 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ CC = gcc OBJS = trace.o symbols.o stack.o pvtrace: $(OBJS) - gcc -o $@ $(OBJS) + gcc -o $@ $(OBJS) -lbsd .c.o: $(CC) $(CFLAGS) -Wall -c $< diff --git a/symbols.c b/symbols.c index 70627b7..be4ab32 100644 --- a/symbols.c +++ b/symbols.c @@ -17,6 +17,10 @@ #include "stack.h" #include "symbols.h" +#if defined(__linux__) +#include +#endif + func_t functions[MAX_FUNCTIONS]; unsigned int totals[MAX_FUNCTIONS]; unsigned int calls[MAX_FUNCTIONS][MAX_FUNCTIONS]; @@ -60,7 +64,7 @@ translateFunctionFromSymbol(unsigned int address, char *func) { FILE *p; char line[100]; - int len, i; + int i; snprintf(line, sizeof(line), "addr2line -e %s -f -s 0x%x", imageName, address); @@ -69,7 +73,7 @@ translateFunctionFromSymbol(unsigned int address, char *func) if (p == NULL) return 0; - len = fread(line, 99, 1, p); + fread(line, 99, 1, p); for (i = 0; i < strlen(line); i++) { if ((line[i] == 0x0d) || (line[i] == 0x0a)) { -- cgit v1.2.3