adamgreen / CrashCatcher

Catch Hard Faults on Cortex-M devices and save out a crash dump to be used by CrashDebug.
Apache License 2.0
220 stars 49 forks source link

Avoid warning about unused parameter #10

Closed strongly-typed closed 5 years ago

strongly-typed commented 5 years ago
CrashCatcher.c:178:41: warning: unused parameter 'pObject' [-Wunused-parameter]
 static void dumpSignature(const Object* pObject)
adamgreen commented 5 years ago

The makefile in this project disables that parameter warning.

Maybe it would be better to just remove the pObject parameter altogether + modify the LocalFileSystem sample to silence the same warning.

diff --git a/Core/src/CrashCatcher.c b/Core/src/CrashCatcher.c
index 9a3b8c3..8782002 100644
--- a/Core/src/CrashCatcher.c
+++ b/Core/src/CrashCatcher.c
@@ -55,7 +55,7 @@ static int areFloatingPointCoprocessorsEnabled(void);
 static void initIsBKPT(Object* pObject);
 static int isBKPT(uint16_t instruction);
 static void setStackSentinel(void);
-static void dumpSignature(const Object* pObject);
+static void dumpSignature(void);
 static void dumpFlags(const Object* pObject);
 static void dumpR0toR3(const Object* pObject);
 static void dumpR4toR11(const Object* pObject);
@@ -82,7 +82,7 @@ void CrashCatcher_Entry(const CrashCatcherExceptionRegisters* pExceptionRegister
     {
         setStackSentinel();
         CrashCatcher_DumpStart(&object.info);
-        dumpSignature(&object);
+        dumpSignature();
         dumpFlags(&object);
         dumpR0toR3(&object);
         dumpR4toR11(&object);
@@ -175,7 +175,7 @@ static void setStackSentinel(void)
     g_crashCatcherStack[0] = CRASH_CATCHER_STACK_SENTINEL;
 }

-static void dumpSignature(const Object* pObject)
+static void dumpSignature(void)
 {
     static const uint8_t signature[4] = {CRASH_CATCHER_SIGNATURE_BYTE0,
                                          CRASH_CATCHER_SIGNATURE_BYTE1,
diff --git a/samples/LocalFileSystem/LocalFileSystem.c b/samples/LocalFileSystem/LocalFileSystem.c
index 521f4af..b6aed0a 100644
--- a/samples/LocalFileSystem/LocalFileSystem.c
+++ b/samples/LocalFileSystem/LocalFileSystem.c
@@ -36,6 +36,7 @@ static void infiniteLoop(void);

 void CrashCatcher_DumpStart(const CrashCatcherInfo* pInfo)
 {
+    (void)pInfo;
     g_coreDumpFile = semihost_open("crash.dmp", OPEN_W

Edit: I improved my diff.

strongly-typed commented 5 years ago

Dear Adam, thank you for your feedback. As we (@salkinium et al in modm) use your code in another project, we compile it with let call them 'stricter' warnings. Removing the parameter altogether for dumpSignature is an option for me as well. I will modify my PR.

strongly-typed commented 5 years ago

Done.

adamgreen commented 5 years ago

Thanks for the updates! Looks good to me! I have merged and tested.