From 3b05f4a8a3e80945f585ec6bfdeb223aae4dae85 Mon Sep 17 00:00:00 2001 From: dsilverm Date: Sat, 12 Nov 2011 11:42:08 +0000 Subject: [PATCH] addressing coverity warnings: now checking return value of fscanf --- EMCAL/AliCaloRawAnalyzerPeakFinder.cxx | 29 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/EMCAL/AliCaloRawAnalyzerPeakFinder.cxx b/EMCAL/AliCaloRawAnalyzerPeakFinder.cxx index 8d627019efc..24f7df1dfba 100644 --- a/EMCAL/AliCaloRawAnalyzerPeakFinder.cxx +++ b/EMCAL/AliCaloRawAnalyzerPeakFinder.cxx @@ -287,6 +287,9 @@ AliCaloRawAnalyzerPeakFinder::LoadVectorsASCII() FILE *fp = fopen(filename, "r"); FILE *fpc = fopen(filenameCoarse, "r"); + + int status = 0; + int statusc = 0; if( fp == 0 ) { @@ -299,17 +302,23 @@ AliCaloRawAnalyzerPeakFinder::LoadVectorsASCII() else { for(int m = 0; m < n ; m++ ) - { - fscanf(fp, "%lf\t", &fPFAmpVectors[i][j][m] ); - fscanf(fpc, "%lf\t", &fPFAmpVectorsCoarse[i][j][m] ); - } - fscanf(fp, "\n" ); - fscanf(fpc, "\n" ); + { + status = fscanf(fp, "%lf\t", &fPFAmpVectors[i][j][m] ); + statusc = fscanf(fpc, "%lf\t", &fPFAmpVectorsCoarse[i][j][m] ); + if (!status) { AliFatal( Form( "could not read file: %s", filename ) ); } + if (!statusc) { AliFatal( Form( "could not read file: %s", filenameCoarse ) ); } + } + status = fscanf(fp, "\n" ); + statusc = fscanf(fpc, "\n" ); + if (status < 0) { AliFatal( Form( "could not read file: %s", filename ) ); } + if (statusc < 0) { AliFatal( Form( "could not read file: %s", filenameCoarse ) ); } for(int m = 0; m < n ; m++ ) - { - fscanf(fp, "%lf\t", &fPFTofVectors[i][j][m] ); - fscanf(fpc, "%lf\t", &fPFTofVectorsCoarse[i][j][m] ); - } + { + status = fscanf(fp, "%lf\t", &fPFTofVectors[i][j][m] ); + statusc = fscanf(fpc, "%lf\t", &fPFTofVectorsCoarse[i][j][m] ); + if (!status) { AliFatal( Form( "could not read file: %s", filename ) ); } + if (!statusc) { AliFatal( Form( "could not read file: %s", filenameCoarse ) ); } + } fPeakFinderVectors->SetVector( i, j, fPFAmpVectors[i][j], fPFTofVectors[i][j], fPFAmpVectorsCoarse[i][j], fPFTofVectorsCoarse[i][j] ); -- 2.39.3