about rule20.5 - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17) +---- Forum: 6.20 Standard Libraries (https://forum.misra.org.uk/forumdisplay.php?fid=42) +---- Thread: about rule20.5 (/showthread.php?tid=740) |
about rule20.5 - raghaw_k - 25-05-2010 According to the rule 20.5, error indiaction facility should not be used even if it is well defined. 1)Is it mean that we should not declare the identifier(function and variable) with the name "errno"? 2)As per the standard library for linux "errno" MACRO is defined to function pointer call and for Visual C++ it is extern variable declaration. So does usage of "errno"(i.e. function call) on linux also violates the rule 20.5? Re: about rule20.5 - Lundin - 26-05-2010 According to the rule "errno" shouldnt be used at all, because it -isn't- well defined. It is only relevant how it is defined in ISO C, not in some homemade C standard for this or that OS. Re: about rule20.5 - Pundlik Oulkar - 27-05-2010 void foo() { int errno; errno = GetValue(); if(errno == 0) //Is this usage of errno violates the rule 20.5, errno is user defined variable not from the errno.h { } } int GetValue() { return 10; } Re: about rule20.5 - MMouse - 27-05-2010 Lundin Wrote:According to the rule "errno" shouldnt be used at all, because it -isn't- well defined. It is only relevant how it is defined in ISO C, not in some homemade C standard for this or that OS. I agree. Linux is written using GCC which has it's own standard. It is not ISO -C more to the point there are no defined error numbers in ISO-C. Everything says there "may" be an error number. No specification to what the error number is. BTW I once, well over a decade ago, had an error routine that checked for any return >0. Trouble was one (and only one) funnction in the library used negative numbers for errors... I have never found any consistancy between any compiler libraries on errno. The only consistancy is those compilers who share the same library. Whilst this will usually work for for commercial compilers wherey they tend to use the same library across all their compilers for GCC the inverse is true as there are very many different libraries available. So no two people using, for example, a GCC-ARM compiler may be using the same library. Thus the errno might/will be different or missing all together. Re: about rule20.5 - Lundin - 28-05-2010 Why would you use Linux & GCC on a safety-critical application anyhow... It will be an incredible painful and time-consuming process to ensure that the tool lives up to MISRA, let alone Linux itself. For example, MISRA mentiones that the maker of the tool should have a quality system, validation activities etc etc. How you can say that a semi-hobbyist open-source compiler lives up to that, I have no idea. Re: about rule20.5 - William Forbes - 30-05-2010 Lundin Wrote:How you can say that a semi-hobbyist open-source compiler lives up to that, I have no idea.This is a bit unfair. The GCC compiler is probably the most widely tested piece of software ever written. It also forms the core of some very expensive commercial compilers used in safety critical software. Bill Forbes Re: about rule20.5 - MMouse - 30-05-2010 William Forbes Wrote:Lundin Wrote:How you can say that a semi-hobbyist open-source compiler lives up to that, I have no idea.This is a bit unfair. The GCC compiler is probably the most widely tested piece of software ever written. I don't see how you can say that.... GCC is very widely used BUT most are as individual as people. GCC is the GNU Compiler Colection. It is a generic compiler but there are many versions maintained by many different people for many different targets. The code in the compilers comes from many different (uncontrolled) sources of varying standards. Most people download and build their own in uncontrolled "processes" and build and use it with any number of different libraries..... It is like doing an IQ test on one person and extrapolating it out to the whole human race. There is no GCC test suite as such either. I know some one who looked at the suposed test suite ad said it is an unstructured incomplete partial regressiont test suite or poor quality with no provenance.... I understand that a couple of people have put one or two of the GCC compilers though the Pum-Hall and Perenial test suites with poor results.... though to be fair they are ISO C test suites not GCC test suites. So many thousands of [different] GCC compilers have been tested to some extent with some test suites of varying quality. Which compilers used in safety critical work does it form the core for? Re: about rule20.5 - misra-c - 31-05-2010 (1) "errno", like many other identifiers used in the standard headers, is reserved so you should NOT attempt to use it for your own purposes. You could use something like error_number instead. (2) The standard permits errno to be implemented as a macro or as an identifier declared with external linkage. It is a violation of rule 20.5 to use errno, regardless of its implementation. As pointed out by previous correspondents errno has a lot of implementation defined behaviour associated with it in ISO C. Re: about rule20.5 - Lundin - 11-06-2010 William Forbes Wrote:Lundin Wrote:How you can say that a semi-hobbyist open-source compiler lives up to that, I have no idea.This is a bit unfair. The GCC compiler is probably the most widely tested piece of software ever written. Yes it is very well-tested. Yet it doesn't conform to ISO C 9899:1990 as enforced by MISRA. It implements some hybrid between C90 and C99, best referred to as "GCC C". Thus it is a hobbyist project of creating a new language, and not relevant for C90 applications. |