From f6a7672e595ed9d26bc1952ea287e81ba0d1f7c5 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 5 Mar 2021 12:08:34 +0000 Subject: [PATCH] Compiler warning re strncpy --- fortran/grib_fortran.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index 289e2c5b4..87bc33ae0 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -2148,9 +2148,9 @@ int grib_f_print(int* gid, char* key, int len){ /*****************************************************************************/ int grib_f_get_error_string_(int* err, char* buf, int len){ const char* err_msg = grib_get_error_message(*err); - size_t erlen = strlen(err_msg); + const size_t erlen = strlen(err_msg); if( len < erlen) return GRIB_ARRAY_TOO_SMALL; - strncpy(buf, err_msg,(size_t)erlen); + strncpy(buf, err_msg,(size_t)len); return GRIB_SUCCESS; } int grib_f_get_error_string__(int* err, char* buf, int len){