Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
about rule20.5
#1
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?
<t></t>
Reply
#2
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.
<t></t>
Reply
#3
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;
}
<r><COLOR color="#FF40FF"><s></s>Pundlik Oulkar<e></e></COLOR></r>
Reply
#4
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.
Reply
#5
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.
<t></t>
Reply
#6
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
<t></t>
Reply
#7
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.
It also forms the core of some very expensive commercial compilers used in safety critical software.

Bill Forbes

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?
Reply
#8
(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.
Posted by and on behalf of the MISRA C Working Group
Reply
#9
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.
It also forms the core of some very expensive commercial compilers used in safety critical software.

Bill Forbes

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.
<t></t>
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)