This appears to be an attempt of blocking MISRA diagnostics for rule 10.5. Which is about value conversions to the inappropriate essential type and not about (null) pointer conversions, so it is senseless. Except if this is an attempt to block incorrect diagnostics by a broken static analyser like this one.
There's a more relevant MISRA rule stating that NULL
shall never be (re)defined by the application in the first place. And yet another rule that NULL
is the only allowed form of a null pointer constant. Blocking those diagnostics would make more sense, especially if you are the one implementing the standard library stddef.h
.
As for what the pragmas do, it is common that pragmas "stack" (push/pop) message settings locally, so that you can disable a certain message just at one single place instead of in the whole project or at every trailing line from the point of the pragma. The purpose of the second pragma is to restore the default message settings.
Something like this might not be feasible(?):
#pragma nomisrac 10.5
#define NULL 0
#pragma nomisrac restore
I'm just guessing now, but since there is not necessarily any relation between #pragma
and #define
as such, perhaps the compiler/static analyser will still complain when this macro is fetched into some translation unit and expanded there.
Or alternatively there is no rationale and the programmer just liked to smack everything into a single line.