Request - remove SDK warnings raised by -Wextra

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Request - remove SDK warnings raised by -Wextra

Jump to solution
811 Views
dmarks_ls
Senior Contributor I

I have a humble request that hopefully will improve the lives of everyone using your SDK... please update your SDK source code so that it compiles without warnings when the -Wextra option is enabled.  This would greatly assist customers who need to demonstrate compliance with the MISRA C:2012 code safety guidelines, and is just a good idea in general.

It's not difficult... I've done it on my RT1050 project, took maybe an hour to do.  (Caveat; that project currently uses SDK 2.7.0, so if you've already undertaken this activity in a subsequent SDK version, thank you in advance.)  

95% of the modifications I had to make were explicitly casting unused function parameters to void in order to silence the warning about unused function parameters.  My recommendation is to add a macro definition to fsl_common.h:

/* Removes warning about unused parameter. */
#define FSL_UNUSED(param) ((void)(param))

Then modify any affected function like so:

static void SPDIF_RxEDMACallback(edma_handle_t *handle, void *userData, bool done, uint32_t tcds)
{
FSL_UNUSED(handle);
FSL_UNUSED(done);
FSL_UNUSED(tcds);
{ ... }
}

Another warning that's enabled is switch/case fallthrough; I don't think there are any instances of that in the SDK.  But one warning that does appear is about signed/unsigned comparison which occurs in this function:

static ENET_Type *ethernetif_get_enet_base(const uint8_t enetIdx)
{
ENET_Type* enets[] = ENET_BASE_PTRS;
int arrayIdx;
int enetCount;

for (arrayIdx = 0, enetCount = 0; arrayIdx < ARRAY_SIZE(enets); arrayIdx++)
{
if (enets[arrayIdx] != 0U) /* process only defined positions */
{ /* (some SOC headers count ENETs from 1 instead of 0) */
if (enetCount == enetIdx)
{
return enets[arrayIdx];
}
enetCount++;
}
}
return NULL;
}

Changing the declarations of the counters fixes this:

size_t arrayIdx;
size_t enetCount;

There were about 40-50 SDK files that I had to modify in order to silence all the new warnings.  If you would keep -Wextra enabled while developing and testing the SDK source code, it would reduce the burden on developers who are trying to comply with code quality standards.  Plus, it just makes your code better.  Thanks.

David R.

(BTW, your new forum software is terrible and I hate it.)

0 Kudos
1 Solution
795 Views
gusarambula
NXP TechSupport
NXP TechSupport

Hello David R.,

I will escalate your recommendation so that it’s considered. However, it may take some time to be implemented depending on work being done to the SDK at the time.

My apologies for the inconvenience.

Regards,
Gustavo

P.S. I agree that the previous forums were more intuitive. Hopefully there will be improvements over time to make it more accessible.

View solution in original post

1 Reply
796 Views
gusarambula
NXP TechSupport
NXP TechSupport

Hello David R.,

I will escalate your recommendation so that it’s considered. However, it may take some time to be implemented depending on work being done to the SDK at the time.

My apologies for the inconvenience.

Regards,
Gustavo

P.S. I agree that the previous forums were more intuitive. Hopefully there will be improvements over time to make it more accessible.