From 87b63c2a6813d7024aa9fc48dfd5d4677462b383 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 15 May 2014 16:33:11 +0200 Subject: GNUmakefile: enable support for CC env variable to use e.g. clang Signed-off-by: Danny Al-Gaaf --- GNUmakefile | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 7a74ec3..f387e30 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -91,6 +91,11 @@ ifndef DESTDIR DESTDIR := /usr endif +# -------------------------------------------------------------------------- +# Compiler CC handling +ifndef CC + CC := gcc +endif # -------------------------------------------------------------------------- # Acquire configuration information for libraries that libs3 depends upon @@ -205,18 +210,18 @@ uninstall: $(BUILD)/obj/%.o: src/%.c $(QUIET_ECHO) $@: Compiling object @ mkdir -p $(dir $(BUILD)/dep/$<) - @ gcc $(CFLAGS) -M -MG -MQ $@ -DCOMPILINGDEPENDENCIES \ + @ $(CC) $(CFLAGS) -M -MG -MQ $@ -DCOMPILINGDEPENDENCIES \ -o $(BUILD)/dep/$(<:%.c=%.d) -c $< @ mkdir -p $(dir $@) - $(VERBOSE_SHOW) gcc $(CFLAGS) -o $@ -c $< + $(VERBOSE_SHOW) $(CC) $(CFLAGS) -o $@ -c $< $(BUILD)/obj/%.do: src/%.c $(QUIET_ECHO) $@: Compiling dynamic object @ mkdir -p $(dir $(BUILD)/dep/$<) - @ gcc $(CFLAGS) -M -MG -MQ $@ -DCOMPILINGDEPENDENCIES \ + @ $(CC) $(CFLAGS) -M -MG -MQ $@ -DCOMPILINGDEPENDENCIES \ -o $(BUILD)/dep/$(<:%.c=%.dd) -c $< @ mkdir -p $(dir $@) - $(VERBOSE_SHOW) gcc $(CFLAGS) -fpic -fPIC -o $@ -c $< + $(VERBOSE_SHOW) $(CC) $(CFLAGS) -fpic -fPIC -o $@ -c $< # -------------------------------------------------------------------------- @@ -236,7 +241,7 @@ LIBS3_SOURCES := acl.c bucket.c error_parser.c general.c \ $(LIBS3_SHARED): $(LIBS3_SOURCES:%.c=$(BUILD)/obj/%.do) $(QUIET_ECHO) $@: Building shared library @ mkdir -p $(dir $@) - $(VERBOSE_SHOW) gcc -shared -Wl,-soname,libs3.so.$(LIBS3_VER_MAJOR) \ + $(VERBOSE_SHOW) $(CC) -shared -Wl,-soname,libs3.so.$(LIBS3_VER_MAJOR) \ -o $@ $^ $(LDFLAGS) $(LIBS3_STATIC): $(LIBS3_SOURCES:%.c=$(BUILD)/obj/%.o) @@ -254,7 +259,7 @@ s3: $(BUILD)/bin/s3 $(BUILD)/bin/s3: $(BUILD)/obj/s3.o $(LIBS3_SHARED) $(QUIET_ECHO) $@: Building executable @ mkdir -p $(dir $@) - $(VERBOSE_SHOW) gcc -o $@ $^ $(LDFLAGS) + $(VERBOSE_SHOW) $(CC) -o $@ $^ $(LDFLAGS) # -------------------------------------------------------------------------- @@ -278,7 +283,7 @@ test: $(BUILD)/bin/testsimplexml $(BUILD)/bin/testsimplexml: $(BUILD)/obj/testsimplexml.o $(LIBS3_STATIC) $(QUIET_ECHO) $@: Building executable @ mkdir -p $(dir $@) - $(VERBOSE_SHOW) gcc -o $@ $^ $(LIBXML2_LIBS) + $(VERBOSE_SHOW) $(CC) -o $@ $^ $(LIBXML2_LIBS) # -------------------------------------------------------------------------- -- cgit v1.2.1 From 2fb69e98130da6f74c12dd8c3b595c960a821995 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 15 May 2014 16:36:20 +0200 Subject: util.h: fix MAX_URI_SIZE sizeof usage Fix for : inc/request.h:131:14: error: sizeof on pointer operation will return size of 'char *' instead of 'char [9]' [-Werror,-Wsizeof-array-decay] Signed-off-by: Danny Al-Gaaf --- inc/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/util.h b/inc/util.h index 4138ca7..94ed0e7 100644 --- a/inc/util.h +++ b/inc/util.h @@ -58,7 +58,7 @@ // 255 is the maximum bucket length #define MAX_URI_SIZE \ ((sizeof("https:///") - 1) + S3_MAX_HOSTNAME_SIZE + 255 + 1 + \ - MAX_URLENCODED_KEY_SIZE + (sizeof("?torrent" - 1)) + 1) + MAX_URLENCODED_KEY_SIZE + (sizeof("?torrent") - 1) + 1) // Maximum size of a canonicalized resource #define MAX_CANONICALIZED_RESOURCE_SIZE \ -- cgit v1.2.1 From 1776f1fb548026d70f2354002cb5316844b69879 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 15 May 2014 16:45:14 +0200 Subject: s3.c: fix potential null pointer dereference Fix for scan-build report: 387 (*gb)->prev->next = buf; 25 Access to field 'next' results in a dereference of a null pointer (loaded from field 'prev') Signed-off-by: Danny Al-Gaaf --- src/s3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s3.c b/src/s3.c index 65acc52..e6b683b 100644 --- a/src/s3.c +++ b/src/s3.c @@ -376,7 +376,7 @@ static int growbuffer_append(growbuffer **gb, const char *data, int dataLen) } buf->size = 0; buf->start = 0; - if (*gb) { + if (*gb && (*gb)->prev) { buf->prev = (*gb)->prev; buf->next = *gb; (*gb)->prev->next = buf; -- cgit v1.2.1 From 2f602bce782be221a729a74df1258fdf896e633b Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 15 May 2014 18:16:12 +0200 Subject: Fix some non-ANSI function declaration Add void in case no function parameters are declared. Signed-off-by: Danny Al-Gaaf --- src/general.c | 2 +- src/request.c | 2 +- src/s3.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/general.c b/src/general.c index fb30c37..867ae5d 100644 --- a/src/general.c +++ b/src/general.c @@ -43,7 +43,7 @@ S3Status S3_initialize(const char *userAgentInfo, int flags, } -void S3_deinitialize() +void S3_deinitialize(void) { if (--initializeCountG) { return; diff --git a/src/request.c b/src/request.c index b267a5e..53bda41 100644 --- a/src/request.c +++ b/src/request.c @@ -1109,7 +1109,7 @@ S3Status request_api_initialize(const char *userAgentInfo, int flags, } -void request_api_deinitialize() +void request_api_deinitialize(void) { pthread_mutex_destroy(&requestStackMutexG); diff --git a/src/s3.c b/src/s3.c index e6b683b..11f54af 100644 --- a/src/s3.c +++ b/src/s3.c @@ -141,7 +141,7 @@ static char putenvBufG[256]; // util ---------------------------------------------------------------------- -static void S3_init() +static void S3_init(void) { S3Status status; const char *hostname = getenv("S3_HOSTNAME"); @@ -155,7 +155,7 @@ static void S3_init() } -static void printError() +static void printError(void) { if (statusG < S3StatusErrorAccessDenied) { fprintf(stderr, "\nERROR: %s\n", S3_get_status_name(statusG)); @@ -675,7 +675,7 @@ static int convert_simple_acl(char *aclXml, char *ownerId, return 1; } -static int should_retry() +static int should_retry(void) { if (retriesG--) { // Sleep before next retry; start out with a 1 second sleep -- cgit v1.2.1