Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Conditional stream opening and 22.3?
#1
Does the rule prohibit cases like the following:
Code:
if( someCondition )
    f = fopen( "apple", "r+" );
else
    f = fopen( "apple", "r" );
g = fopen( "apple", "r+" );
Reply
#2
Quite simply, yes

The example you cite is no different to the example in the Guideline for !someCondition

However, of course, if the stream is closed before the subsequent opening, then that would be OK.
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)