#This script is designed to run with Understand - CodeCheck use base ("Understand::Codecheck"); use strict; use constant ERR1 => ' included in file %1'; sub register_tr_text() { my $check = shift; $check->add_tr_text(ERR1); } sub name { return "20.9 The input output library shall not be used in production code";} sub description { return "20.9 (Required) The input output library shall not be used in production code";} sub detailed_description { return <<"END_DESC"

This includes file and I/O functions fgetpos, fopen, ftell, gets, perror, remove, rename and ungetc.

Streams and file I/O have a large number of unspecified, undefined and implementation-defined behaviours associated with them. It is assumed within this document that they will not normally be needed in production code in embedded systems. If any of the features of stdio.h need to be used in production code, then the issues associated with the feature need to be understood.

END_DESC } sub test_language { my $language = shift; return $language =~ /C\+\+/; #Handles C and C++ } sub test_entity { return 1;} sub test_global { return 0;} sub define_options{} sub check { my $check = shift; my $file = shift; return unless $file->kind->check("file ~unknown ~unresolved"); foreach my $includes($file->filerefs("include","file")){ if($includes->ent->name eq "stdio.h"){ $check->violation($includes->ent,$file,$includes->line,$includes->column,ERR1,$file->name); } } }