From bf537dedf5f7d5990c51a84017111a1ed2bb614a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 19 Oct 2019 10:49:05 -0400 Subject: [PATCH] check status of ftruncate() in ave/* fixes --- src/USER-MISC/fix_ave_correlate_long.cpp | 3 ++- src/fix_ave_chunk.cpp | 3 ++- src/fix_ave_correlate.cpp | 3 ++- src/fix_ave_histo.cpp | 3 ++- src/fix_ave_histo_weight.cpp | 3 ++- src/fix_ave_time.cpp | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/USER-MISC/fix_ave_correlate_long.cpp b/src/USER-MISC/fix_ave_correlate_long.cpp index b1bcc07fa7..3a28e47cda 100644 --- a/src/USER-MISC/fix_ave_correlate_long.cpp +++ b/src/USER-MISC/fix_ave_correlate_long.cpp @@ -504,7 +504,8 @@ void FixAveCorrelateLong::end_of_step() fflush(fp); if (overwrite) { long fileend = ftell(fp); - if (fileend > 0) ftruncate(fileno(fp),fileend); + if ((fileend > 0) && (ftruncate(fileno(fp),fileend))) + perror("Error while tuncating output"); } } diff --git a/src/fix_ave_chunk.cpp b/src/fix_ave_chunk.cpp index 45eb38f5c2..0ebdddb9df 100644 --- a/src/fix_ave_chunk.cpp +++ b/src/fix_ave_chunk.cpp @@ -1055,7 +1055,8 @@ void FixAveChunk::end_of_step() if (overwrite) { long fileend = ftell(fp); - if (fileend > 0) ftruncate(fileno(fp),fileend); + if ((fileend > 0) && (ftruncate(fileno(fp),fileend))) + perror("Error while tuncating output"); } } } diff --git a/src/fix_ave_correlate.cpp b/src/fix_ave_correlate.cpp index f65b53efc8..0a8a4cd17f 100644 --- a/src/fix_ave_correlate.cpp +++ b/src/fix_ave_correlate.cpp @@ -535,7 +535,8 @@ void FixAveCorrelate::end_of_step() if (overwrite) { long fileend = ftell(fp); - if (fileend > 0) ftruncate(fileno(fp),fileend); + if ((fileend > 0) && (ftruncate(fileno(fp),fileend))) + perror("Error while tuncating output"); } } diff --git a/src/fix_ave_histo.cpp b/src/fix_ave_histo.cpp index 5a5de6d0b6..1a292bf8d2 100644 --- a/src/fix_ave_histo.cpp +++ b/src/fix_ave_histo.cpp @@ -851,7 +851,8 @@ void FixAveHisto::end_of_step() fflush(fp); if (overwrite) { long fileend = ftell(fp); - if (fileend > 0) ftruncate(fileno(fp),fileend); + if ((fileend > 0) && (ftruncate(fileno(fp),fileend))) + perror("Error while tuncating output"); } } } diff --git a/src/fix_ave_histo_weight.cpp b/src/fix_ave_histo_weight.cpp index f4ff0ae55f..4b86681153 100644 --- a/src/fix_ave_histo_weight.cpp +++ b/src/fix_ave_histo_weight.cpp @@ -493,7 +493,8 @@ void FixAveHistoWeight::end_of_step() fflush(fp); if (overwrite) { long fileend = ftell(fp); - if (fileend > 0) ftruncate(fileno(fp),fileend); + if ((fileend > 0) && (ftruncate(fileno(fp),fileend))) + perror("Error while tuncating output"); } } } diff --git a/src/fix_ave_time.cpp b/src/fix_ave_time.cpp index 05d556d0c8..90bef7dc65 100644 --- a/src/fix_ave_time.cpp +++ b/src/fix_ave_time.cpp @@ -698,7 +698,8 @@ void FixAveTime::invoke_scalar(bigint ntimestep) if (overwrite) { long fileend = ftell(fp); - if (fileend > 0) ftruncate(fileno(fp),fileend); + if ((fileend > 0) && (ftruncate(fileno(fp),fileend))) + perror("Error while tuncating output"); } } }