ソースを参照

Merge branch 'develop' into feature/#63-add-simple-authentication-mechanism

stefan 9 ヶ月 前
コミット
5f53dccaf6
3 ファイル変更26 行追加11 行削除
  1. 17 1
      api/shellmatta.h
  2. 7 8
      makefile
  3. 2 2
      test/unittest/shellmatta_utils/test_utils_writeEcho.cpp

+ 17 - 1
api/shellmatta.h

@@ -25,6 +25,21 @@
 
 /* global defines */
 
+
+/*
+ * Define the printf format specifier for all GCC versions > 3.3
+ * This will let the compiler know that shelmatta_printf() is a function taking printf-like format specifiers.
+ */
+#ifndef SHELLMATTA_ATTR_FORMAT
+#   if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
+#       define SHELLMATTA_ATTR_FORMAT(fmt, args) __attribute__((__format__(__printf__, fmt, args)))
+#   else
+#       define SHELLMATTA_ATTR_FORMAT(fmt, args)
+#   endif
+#else
+#   define SHELLMATTA_ATTR_FORMAT(fmt, args)
+#endif
+
 /**
  * @brief definition of a shellmatta handle
  */
@@ -274,7 +289,8 @@ shellmatta_retCode_t shellmatta_opt_long(   shellmatta_handle_t         handle,
 #ifndef SHELLMATTA_STRIP_PRINTF
 shellmatta_retCode_t shellmatta_printf(     shellmatta_handle_t handle,
                                             const char          *fmt,
-                                            ...);
+                                            ...)
+                                            SHELLMATTA_ATTR_FORMAT(2, 3);
 #endif
 
 #ifdef SHELLMATTA_AUTHENTICATION

+ 7 - 8
makefile

@@ -161,28 +161,27 @@ $(TARGET): $(OBJ)
 
 $(COBJ):
 	- @mkdir -p $(@D)
-	@$(CC) -c $(CFLAGS)  $(DEPEND) -o $@  $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
+	@$(CC) -c $(CFLAGS) $(DEPEND) -o $(@:%.o=%.d) $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
 	$(CC) -c $(CFLAGS) -o $@  $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
 
 $(EXAMPLE_COBJ):
 	- @mkdir -p $(@D)
-	@echo sdlfkjsdlk
-	@$(CC) -c $(CFLAGS_EXAMPLE) $(DEPEND) -o $@  $(subst $(OBJ_DIR_EXAMPLE), ,$(@:%.o=%.c))
+	@$(CC) -c $(CFLAGS_EXAMPLE) $(DEPEND) -o $(@:%.o=%.d) $(subst $(OBJ_DIR_EXAMPLE), ,$(@:%.o=%.c))
 	$(CC) -c $(CFLAGS_EXAMPLE) -o $@  $(subst $(OBJ_DIR_EXAMPLE), ,$(@:%.o=%.c))
 
 $(UNITTEST_CPPOBJ):
 	- @mkdir -p $(@D)
-	@$(CPP) -c $(TESTFLAGS) $(DEPEND) -o $@  $(subst $(UNITTEST_OBJ_DIR), ,$(@:%.o=%.cpp))
-	$(CPP) -c $(TESTFLAGS) -o $@  $(subst $(UNITTEST_OBJ_DIR), ,$(@:%.o=%.cpp))
+	@$(CPP) -c $(TESTFLAGS) $(DEPEND) -o $(@:%.o=%.d) $(subst $(UNITTEST_OBJ_DIR), ,$(@:%.o=%.cpp))
+	$(CPP) -c $(TESTFLAGS) -o $@ $(subst $(UNITTEST_OBJ_DIR), ,$(@:%.o=%.cpp))
 
 $(INTEGRATIONTEST_CPPOBJ):
 	- @mkdir -p $(@D)
-	@$(CPP) -c $(TESTFLAGS) $(DEPEND) -o $@  $(subst $(INTEGRATIONTEST_CPP_OBJ_DIR), ,$(@:%.o=%.cpp))
+	@$(CPP) -c $(TESTFLAGS) $(DEPEND) -o $(@:%.o=%.d) $(subst $(INTEGRATIONTEST_CPP_OBJ_DIR), ,$(@:%.o=%.cpp))
 	$(CPP) -c $(TESTFLAGS) -o $@  $(subst $(INTEGRATIONTEST_CPP_OBJ_DIR), ,$(@:%.o=%.cpp))
 
 $(INTEGRATIONTEST_COBJ):
 	- @mkdir -p $(@D)
-	@$(CC) -c $(TESTFLAGS) $(DEPEND) -o $@  $(subst $(INTEGRATIONTEST_C_OBJ_DIR), ,$(@:%.o=%.c))
+	@$(CC) -c $(TESTFLAGS) $(DEPEND) -o $(@:%.o=%.d) $(subst $(INTEGRATIONTEST_C_OBJ_DIR), ,$(@:%.o=%.c))
 	$(CC) -c $(TESTFLAGS) -o $@  $(subst $(INTEGRATIONTEST_C_OBJ_DIR), ,$(@:%.o=%.c))
 
 $(INTEGRATIONTEST_AUTH_CPPOBJ):
@@ -197,7 +196,7 @@ $(INTEGRATIONTEST_AUTH_COBJ):
 
 %.o: %.cpp
 	- @mkdir -p $(@D)
-	@$(CPP) -c $(CFLAGS) $(DEPEND) -o $@  $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
+	@$(CPP) -c $(CFLAGS) $(DEPEND) -o $(@:%.o=%.d) $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
 	$(CPP) -c $(CFLAGS) -o $@  $<
 
 -include $(DEPS)

+ 2 - 2
test/unittest/shellmatta_utils/test_utils_writeEcho.cpp

@@ -17,7 +17,7 @@ static shellmatta_retCode_t writeFct(const char* data, uint32_t length)
 TEST_CASE( "shellmatta_writeEcho echo enabled" ) {
 
     shellmatta_instance_t inst;
-    char buffer[20];
+    char buffer[20] = {0};
     char dummyData[29] = {0};
 
     inst.buffer = buffer;
@@ -42,7 +42,7 @@ TEST_CASE( "shellmatta_writeEcho echo enabled" ) {
 TEST_CASE( "shellmatta_writeEcho echo disabled" ) {
 
     shellmatta_instance_t inst;
-    char buffer[20];
+    char buffer[20] = {0};
     char dummyData[29] = {0};
 
     inst.buffer = buffer;