diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-10-28 10:41:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-28 10:41:39 +0100 |
| commit | d9b9afe2b9921b0b3624095b60cca7d630cae67a (patch) | |
| tree | 7865bf5e9b3d7b293f207c10a24fe965a114cfce /src/apply_vgridshift.cpp | |
| parent | e2d5b13f3442a8e88093a9d68e1be550194a4d77 (diff) | |
| parent | 7026fa2241d4e42ac35688487b7c7dd4d7f8bad1 (diff) | |
| download | PROJ-d9b9afe2b9921b0b3624095b60cca7d630cae67a.tar.gz PROJ-d9b9afe2b9921b0b3624095b60cca7d630cae67a.zip | |
Merge pull request #1697 from rouault/cppcheck_fixes
Fixes/workaround to be able to use cppcheck from Ubuntu 16.04 (fixes #1648)
Diffstat (limited to 'src/apply_vgridshift.cpp')
| -rw-r--r-- | src/apply_vgridshift.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/apply_vgridshift.cpp b/src/apply_vgridshift.cpp index 0c1db3dd..daa44858 100644 --- a/src/apply_vgridshift.cpp +++ b/src/apply_vgridshift.cpp @@ -119,13 +119,13 @@ static double read_vgrid_value( PJ *defn, PJ_LP input, double vmultiplier, int * /* load the grid shift info if we don't have it. */ if( ct->cvs == nullptr ) { - if( !pj_gridinfo_load( pj_get_ctx(defn), gi ) || ct->cvs == nullptr ) - { - pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); - return PJD_ERR_FAILED_TO_LOAD_GRID; - } + pj_gridinfo_load( pj_get_ctx(defn), gi ); + } + if( ct->cvs == nullptr ) + { + pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); + return PJD_ERR_FAILED_TO_LOAD_GRID; } - /* Interpolation a location within the grid */ grid_x = (input.lam - ct->ll.lam) / ct->del.lam; @@ -271,7 +271,7 @@ int pj_apply_vgridshift( PJ *defn, const char *listname, if( value == HUGE_VAL ) { int itable; - char gridlist[3000]; + std::string gridlist; proj_log_debug(defn, "pj_apply_vgridshift(): failed to find a grid shift table for\n" @@ -279,23 +279,17 @@ int pj_apply_vgridshift( PJ *defn, const char *listname, x[io] * RAD_TO_DEG, y[io] * RAD_TO_DEG ); - gridlist[0] = '\0'; for( itable = 0; itable < *gridlist_count_p; itable++ ) { PJ_GRIDINFO *gi = tables[itable]; - if( strlen(gridlist) + strlen(gi->gridname) > sizeof(gridlist)-100 ) - { - strcat( gridlist, "..." ); - break; - } - if( itable == 0 ) - sprintf( gridlist, " tried: %s", gi->gridname ); + gridlist += " tried: "; else - sprintf( gridlist+strlen(gridlist), ",%s", gi->gridname ); + gridlist += ','; + gridlist += gi->gridname; } - proj_log_debug(defn, "%s", gridlist); + proj_log_debug(defn, "%s", gridlist.c_str()); pj_ctx_set_errno( defn->ctx, PJD_ERR_GRID_AREA ); return PJD_ERR_GRID_AREA; |
