[rtems commit] bsps/beagle: fix warning on possibly uninitialized clock control in pwmss.

Karel Gardas karel at rtems.org
Sat Feb 18 21:45:25 UTC 2023


Module:    rtems
Branch:    master
Commit:    673d7861e349ceec1b5bd0bf81fa449a6fc9507e
Changeset: http://git.rtems.org/rtems/commit/?id=673d7861e349ceec1b5bd0bf81fa449a6fc9507e

Author:    Karel Gardas <karel at functional.vision>
Date:      Sat Feb 11 20:58:55 2023 +0100

bsps/beagle: fix warning on possibly uninitialized clock control in pwmss.

---

 bsps/arm/beagle/pwmss/pwmss.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/bsps/arm/beagle/pwmss/pwmss.c b/bsps/arm/beagle/pwmss/pwmss.c
index 0fde3db5a9..f3aaf8fc3f 100644
--- a/bsps/arm/beagle/pwmss/pwmss.c
+++ b/bsps/arm/beagle/pwmss/pwmss.c
@@ -38,7 +38,7 @@
 #include <bsp.h>
 #include <bsp/pwmss.h>
 #include <bsp/beagleboneblack.h>
-
+#include <rtems/error.h>
 
 /**
  * @brief   This function configures the L3 and L4_PER system clocks.
@@ -56,7 +56,10 @@
  */
 rtems_status_code pwmss_module_clk_config(BBB_PWMSS pwmss_id)
 {
-    uint32_t clkctrl;
+    /* we initialize clkctrl here to nonsentical value as this is going
+     * to be assigned later anyway. Here assigning 0 is just to kill
+     * warning emitted by the C compiler. */
+    uint32_t clkctrl = 0;
 
     /* calculate the address of the clock control register for the PWMSS
      * module we are configuring */
@@ -66,6 +69,9 @@ rtems_status_code pwmss_module_clk_config(BBB_PWMSS pwmss_id)
         clkctrl = AM335X_CM_PER_ADDR + AM335X_CM_PER_EPWMSS1_CLKCTRL;
     } else if(pwmss_id == BBB_PWMSS2) {
         clkctrl = AM335X_CM_PER_ADDR + AM335X_CM_PER_EPWMSS2_CLKCTRL;
+    } else {
+	/* wrong clock configuration, let's panic here. */
+	rtems_error(RTEMS_ERROR_PANIC, "beagle: unsupported pwmss module clock configuration value!");
     }
 
     /* when the module is functional the IDLEST bits (16 -17) of the



More information about the vc mailing list