From cb9a2ff1daf017a3aee23c70c5210608e19df681 Mon Sep 17 00:00:00 2001
From: Jan Breuer <jan.breuer@jaybee.cz>
Date: 周三, 22 4月 2015 02:37:15 +0800
Subject: [PATCH] Add more compile checks and resolve warnings

---
 examples/test-tcp-srq/Makefile     |    2 
 libscpi/Makefile                   |    2 
 examples/test-interactive/Makefile |    2 
 examples/test-parser/Makefile      |    2 
 examples/test-tcp/Makefile         |    2 
 libscpi/test/test_scpi_utils.c     |   28 +++++++-------
 examples/test-tcp/main.c           |    1 
 examples/test-tcp-srq/main.c       |    1 
 examples/common/scpi-def.c         |   12 +++---
 libscpi/test/test_fifo.c           |    6 +-
 libscpi/test/test_lib.c            |   20 +++++-----
 11 files changed, 40 insertions(+), 38 deletions(-)

diff --git a/examples/common/scpi-def.c b/examples/common/scpi-def.c
index 075f792..116f7dd 100644
--- a/examples/common/scpi-def.c
+++ b/examples/common/scpi-def.c
@@ -40,7 +40,7 @@
 #include "scpi/scpi.h"
 #include "scpi-def.h"
 
-scpi_result_t DMM_MeasureVoltageDcQ(scpi_t * context) {
+static scpi_result_t DMM_MeasureVoltageDcQ(scpi_t * context) {
     scpi_number_t param1, param2;
     char bf[15];
     fprintf(stderr, "meas:volt:dc\r\n"); // debug command name   
@@ -69,7 +69,7 @@
 }
 
 
-scpi_result_t DMM_MeasureVoltageAcQ(scpi_t * context) {
+static scpi_result_t DMM_MeasureVoltageAcQ(scpi_t * context) {
     scpi_number_t param1, param2;
     char bf[15];
     fprintf(stderr, "meas:volt:ac\r\n"); // debug command name   
@@ -97,7 +97,7 @@
     return SCPI_RES_OK;
 }
 
-scpi_result_t DMM_ConfigureVoltageDc(scpi_t * context) {
+static scpi_result_t DMM_ConfigureVoltageDc(scpi_t * context) {
     double param1, param2;
     fprintf(stderr, "conf:volt:dc\r\n"); // debug command name   
 
@@ -117,7 +117,7 @@
     return SCPI_RES_OK;
 }
 
-scpi_result_t TEST_Bool(scpi_t * context) {
+static scpi_result_t TEST_Bool(scpi_t * context) {
     scpi_bool_t param1;
     fprintf(stderr, "TEST:BOOL\r\n"); // debug command name   
 
@@ -139,7 +139,7 @@
 };
 
 
-scpi_result_t TEST_ChoiceQ(scpi_t * context) {
+static scpi_result_t TEST_ChoiceQ(scpi_t * context) {
 
     int32_t param;
     
@@ -154,7 +154,7 @@
     return SCPI_RES_OK;
 }
 
-scpi_result_t TEST_Numbers(scpi_t * context) {
+static scpi_result_t TEST_Numbers(scpi_t * context) {
 
     fprintf(stderr, "RAW CMD %.*s\r\n", (int)context->paramlist.cmd_raw.length, context->paramlist.cmd_raw.data);
 
diff --git a/examples/test-interactive/Makefile b/examples/test-interactive/Makefile
index 3338b7b..400e123 100644
--- a/examples/test-interactive/Makefile
+++ b/examples/test-interactive/Makefile
@@ -2,7 +2,7 @@
 PROG = test
 
 SRCS = main.c ../common/scpi-def.c
-CFLAGS += -Wextra -I ../../libscpi/inc/
+CFLAGS += -Wextra -Wmissing-prototypes -Wimplicit -I ../../libscpi/inc/
 LDFLAGS += ../../libscpi/dist/libscpi.a -Wl,--as-needed
 
 .PHONY: clean all
diff --git a/examples/test-parser/Makefile b/examples/test-parser/Makefile
index 3338b7b..400e123 100644
--- a/examples/test-parser/Makefile
+++ b/examples/test-parser/Makefile
@@ -2,7 +2,7 @@
 PROG = test
 
 SRCS = main.c ../common/scpi-def.c
-CFLAGS += -Wextra -I ../../libscpi/inc/
+CFLAGS += -Wextra -Wmissing-prototypes -Wimplicit -I ../../libscpi/inc/
 LDFLAGS += ../../libscpi/dist/libscpi.a -Wl,--as-needed
 
 .PHONY: clean all
diff --git a/examples/test-tcp-srq/Makefile b/examples/test-tcp-srq/Makefile
index 3338b7b..400e123 100644
--- a/examples/test-tcp-srq/Makefile
+++ b/examples/test-tcp-srq/Makefile
@@ -2,7 +2,7 @@
 PROG = test
 
 SRCS = main.c ../common/scpi-def.c
-CFLAGS += -Wextra -I ../../libscpi/inc/
+CFLAGS += -Wextra -Wmissing-prototypes -Wimplicit -I ../../libscpi/inc/
 LDFLAGS += ../../libscpi/dist/libscpi.a -Wl,--as-needed
 
 .PHONY: clean all
diff --git a/examples/test-tcp-srq/main.c b/examples/test-tcp-srq/main.c
index 8a62f58..a79f9e6 100644
--- a/examples/test-tcp-srq/main.c
+++ b/examples/test-tcp-srq/main.c
@@ -44,6 +44,7 @@
 #include <sys/ioctl.h>
 #include <errno.h>
 #include <arpa/inet.h>
+#include <unistd.h>
 
 #include "scpi/scpi.h"
 #include "../common/scpi-def.h"
diff --git a/examples/test-tcp/Makefile b/examples/test-tcp/Makefile
index 3338b7b..400e123 100644
--- a/examples/test-tcp/Makefile
+++ b/examples/test-tcp/Makefile
@@ -2,7 +2,7 @@
 PROG = test
 
 SRCS = main.c ../common/scpi-def.c
-CFLAGS += -Wextra -I ../../libscpi/inc/
+CFLAGS += -Wextra -Wmissing-prototypes -Wimplicit -I ../../libscpi/inc/
 LDFLAGS += ../../libscpi/dist/libscpi.a -Wl,--as-needed
 
 .PHONY: clean all
diff --git a/examples/test-tcp/main.c b/examples/test-tcp/main.c
index fcd339e..03dbf88 100644
--- a/examples/test-tcp/main.c
+++ b/examples/test-tcp/main.c
@@ -44,6 +44,7 @@
 #include <sys/ioctl.h>
 #include <errno.h>
 #include <arpa/inet.h>
+#include <unistd.h>
 
 #include "scpi/scpi.h"
 #include "../common/scpi-def.h"
diff --git a/libscpi/Makefile b/libscpi/Makefile
index 4a79b9a..1de30fb 100644
--- a/libscpi/Makefile
+++ b/libscpi/Makefile
@@ -1,6 +1,6 @@
 LIBNAME = scpi
 
-CFLAGS += -Wextra -g -Iinc
+CFLAGS += -Wextra -Wmissing-prototypes -Wimplicit -g -Iinc
 LDFLAGS += -Wl,--as-needed
 TESTFLAGS += -lcunit $(CFLAGS)
 
diff --git a/libscpi/test/test_fifo.c b/libscpi/test/test_fifo.c
index bfe7cad..92f051a 100644
--- a/libscpi/test/test_fifo.c
+++ b/libscpi/test/test_fifo.c
@@ -15,15 +15,15 @@
  * CUnit Test Suite
  */
 
-int init_suite(void) {
+static int init_suite(void) {
     return 0;
 }
 
-int clean_suite(void) {
+static int clean_suite(void) {
     return 0;
 }
 
-void testFifo() {
+static void testFifo() {
     fifo_t fifo;
     fifo_init(&fifo);
     int16_t value;
diff --git a/libscpi/test/test_lib.c b/libscpi/test/test_lib.c
index 61d419b..186cecd 100644
--- a/libscpi/test/test_lib.c
+++ b/libscpi/test/test_lib.c
@@ -15,7 +15,7 @@
  * CUnit Test Suite
  */
 
-scpi_result_t text_function(scpi_t* context) {
+static scpi_result_t text_function(scpi_t* context) {
     const char* param;
     size_t param_len;
 
@@ -36,14 +36,14 @@
     return SCPI_RES_OK;
 }
 
-scpi_result_t test_treeA(scpi_t* context) {
+static scpi_result_t test_treeA(scpi_t* context) {
 
     SCPI_ResultInt(context, 10);
 
     return SCPI_RES_OK;
 }
 
-scpi_result_t test_treeB(scpi_t* context) {
+static scpi_result_t test_treeB(scpi_t* context) {
 
     SCPI_ResultInt(context, 20);
 
@@ -187,17 +187,17 @@
 };
 
 
-int init_suite(void) {
+static int init_suite(void) {
     SCPI_Init(&scpi_context);
 
     return 0;
 }
 
-int clean_suite(void) {
+static int clean_suite(void) {
     return 0;
 }
 
-void testCommandsHandling(void) {
+static void testCommandsHandling(void) {
 #define TEST_INPUT(data, output) {                              \
     SCPI_Input(&scpi_context, data, strlen(data));              \
     CU_ASSERT_STRING_EQUAL(output, output_buffer);              \
@@ -231,7 +231,7 @@
     error_buffer_clear();
 }
 
-void testErrorHandling(void) {
+static void testErrorHandling(void) {
     output_buffer_clear();
     error_buffer_clear();
 
@@ -259,7 +259,7 @@
     error_buffer_clear();
 }
 
-void testIEEE4882(void) {
+static void testIEEE4882(void) {
 #define TEST_IEEE4882(data, output) {                           \
     SCPI_Input(&scpi_context, data, strlen(data));              \
     CU_ASSERT_STRING_EQUAL(output, output_buffer);              \
@@ -307,7 +307,7 @@
     TEST_IEEE4882("SYSTem:VERSion?\r\n", "1999.0\r\n");
 }
 
-void testParameters(void) {
+static void testParameters(void) {
     // TODO: test parsin parameters
     
     // TODO: Int
@@ -318,7 +318,7 @@
     // TODO: Choice
 }
 
-void testResults(void) {
+static void testResults(void) {
     // TODO: test producing results
     
     // TODO: String
diff --git a/libscpi/test/test_scpi_utils.c b/libscpi/test/test_scpi_utils.c
index e357b65..4d1f634 100644
--- a/libscpi/test/test_scpi_utils.c
+++ b/libscpi/test/test_scpi_utils.c
@@ -46,15 +46,15 @@
  * CUnit Test Suite
  */
 
-int init_suite(void) {
+static int init_suite(void) {
     return 0;
 }
 
-int clean_suite(void) {
+static int clean_suite(void) {
     return 0;
 }
 
-void test_strnpbrk() {
+static void test_strnpbrk() {
     char str[] = "ahoj";
 
     CU_ASSERT(strnpbrk(str, 4, "a") == (str + 0));
@@ -64,7 +64,7 @@
     CU_ASSERT(strnpbrk(str, 4, "xo") == (str + 2));
 }
 
-void test_longToStr() {
+static void test_longToStr() {
     char str[32];
     size_t len;
 
@@ -75,7 +75,7 @@
     CU_ASSERT(str[2] == '\0');
 }
 
-void test_doubleToStr() {
+static void test_doubleToStr() {
     size_t result;
     char str[50];
 
@@ -97,7 +97,7 @@
     TEST_DOUBLE_TO_STR(-1.3e-30, 8, "-1.3e-30");
 }
 
-void test_strToLong() {
+static void test_strToLong() {
     size_t result;
     int32_t val;
 
@@ -122,7 +122,7 @@
     TEST_STR_TO_LONG("018", 2, 1); // octal 1, 8 is ignored
 }
 
-void test_strToDouble() {
+static void test_strToDouble() {
     double val;
     size_t result;
 
@@ -155,7 +155,7 @@
 
 }
 
-void test_compareStr() {
+static void test_compareStr() {
 
     CU_ASSERT_TRUE(compareStr("abcd", 1, "afgh", 1));
     CU_ASSERT_TRUE(compareStr("ABCD", 4, "abcd", 4));
@@ -166,7 +166,7 @@
     CU_ASSERT_FALSE(compareStr("ABCD", 4, "abcd", 3));
 }
 
-void test_compareStrAndNum() {
+static void test_compareStrAndNum() {
 
     CU_ASSERT_TRUE(compareStrAndNum("abcd", 1, "afgh", 1));
     CU_ASSERT_TRUE(compareStrAndNum("ABCD", 4, "abcd", 4));
@@ -184,7 +184,7 @@
 
 }
 
-void test_locateText() {
+static void test_locateText() {
 
     const char * v;
     const char * b;
@@ -234,7 +234,7 @@
     TEST_LOCATE_TEXT(" \"a\" , a ", TRUE, 2, 1);
 }
 
-void test_locateStr() {
+static void test_locateStr() {
 
     const char * v;
     const char * b;
@@ -282,7 +282,7 @@
     TEST_LOCATE_STR(" \"a\" , a ", TRUE, 1, 3);
 }
 
-void test_matchPattern() {
+static void test_matchPattern() {
     scpi_bool_t result;
     
 #define TEST_MATCH_PATTERN(p, s, r)                             \
@@ -298,7 +298,7 @@
     TEST_MATCH_PATTERN("AB", "a", FALSE);
 }
 
-void test_matchCommand() {
+static void test_matchCommand() {
     scpi_bool_t result;
     
     #define TEST_MATCH_COMMAND(p, s, r)                         \
@@ -424,7 +424,7 @@
     TEST_MATCH_COMMAND("OUTPut#[:MODulation#]:FM#", "output:fm", TRUE); // test numeric parameter
 }
 
-void test_composeCompoundCommand(void) {
+static void test_composeCompoundCommand(void) {
     
 #define TEST_COMPOSE_COMMAND(b, c1_len, c2_pos, c2_len, c2_final, r)    \
     {                                                                   \

--
Gitblit v1.9.1