This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SVCALL warning messages

I've recently upgraded my IDE to use Crossworks v3.6.2 which uses a GCC ARM Embedded 4.9-2015-q3-update compiler. it has by default many of the code clean up featues turned on. it has found a great many warning messages, and I was wondering if there was a quick way to clean them up.

1> c:....\s110\headers\nrf_soc.h: In function 'sd_mutex_new': 1> c:....\s110\headers\nrf_soc.h:374:59: warning: unused parameter 'p_mutex' [-Wunused-parameter] 1> c:....\s110\headers\nrf_svc.h:52:45: note: in definition of macro 'SVCALL' 1> c:....\s110\headers\nrf_soc.h: In function 'sd_mutex_acquire': 1> c:....\s110\headers\nrf_soc.h:383:67: warning: unused parameter 'p_mutex' [-Wunused-parameter] 1> c:....\s110\headers\nrf_svc.h:52:45: note: in definition of macro 'SVCALL' 1> c:....\s110\headers\nrf_soc.h: In function 'sd_mutex_release':

The code line in question is

SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(ble_enable_params_t * p_ble_enable_params));

and SVCALL is linked to this

#define SVCALL(number, return_type, signature) \
  _Pragma("GCC diagnostic ignored \"-Wunused-function\"") \
  _Pragma("GCC diagnostic push") \
  _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
  __attribute__((naked)) static return_type signature \
  { \
    __asm( \
        "svc %0\n" \
        "bx r14" : : "I" (number) : "r0" \
    ); \
  }    \
  _Pragma("GCC diagnostic pop")

All the SVCALL's produce the same warning messages. like 1300 warnings from the Nordic SDK.

I've tried adding the preprocessor define SVCALL_AS_NORMAL_FUNCTION, but now my various calls that were inside a SVCALL, "don't exist" any longer. which I assume is because they are in the softdevice.

Some direction would be great. Thanks

  • This change should stop the warnings from coming up.
    Credit to this answer.
    Cast number as uint16_t, and ignore -Wunused-parameter
    Note: it doesn't actually fix the unused parameter warnings just masks them

    #define SVCALL(number, return_type, signature) \
      _Pragma("GCC diagnostic ignored \"-Wunused-function\"") \
      _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") \
      _Pragma("GCC diagnostic push") \
      _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
      __attribute__((naked)) static return_type signature \
      { \
        __asm( \
            "svc %0\n" \
            "bx r14" : : "I" ((uint16_t)number) : "r0" \
        ); \
      }    \
      _Pragma("GCC diagnostic pop")
    
  • This error occurs with GCC when -Wunused-parameter is enabled (either directly or both other options such as -Wextra). It seems that using GCC pragmas to turn off unused parameter warnings does not work; the GCC 'unused' attribute must be attached directly to the unused parameter.

    A tedious workaround for this problem is to modify nrf_svc.h as follows by adding SVC_PARAM macro:

    #ifdef SVCALL_AS_NORMAL_FUNCTION
    #define SVCALL(number, return_type, signature) return_type signature
    #define SVC_PARAM(x)  x
    #else
    
    
    #if defined (__GNUC__)
    #define SVC_PARAM(x)  SVC_PARAM_ ## x __attribute__((__unused__))
    #else
    #define SVC_PARAM(x)  x
    #endif    
    ...
    

    In each of the instances where the SVCALL() macro is used, modify each call as follows, replacing the parameter name X with SVC_PARAM(X). This will apply the unused GCC attribute directly to the parameter when the SoftDevice is compiled using SVC instructions.

    Before:

    SVCALL(SD_RAND_APPLICATION_VECTOR_GET, uint32_t, sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length));
    

    After:

     SVCALL(SD_MUTEX_NEW, uint32_t, sd_mutex_new(nrf_mutex_t * SVC_PARAM(p_mutex)));
    SVCALL(SD_RAND_APPLICATION_VECTOR_GET, uint32_t, sd_rand_application_vector_get(uint8_t * SVC_PARAM(p_buff), uint8_t SVC_PARAM(length)));
    

    @nordicdevs Is there any chance that a change to the SoftDevice source could be made to accommodate removal of unused parameter warnings on GCC?

Related