Skip to content

Commit

Permalink
Merge pull request #3857 from rouault/fix_warning_cs2cs_emulation_setup
Browse files Browse the repository at this point in the history
Fix false-positive compiler warning
  • Loading branch information
rouault committed Aug 24, 2023
2 parents 5d9df64 + 8b36c19 commit b132ad6
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/4D_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,10 +920,8 @@ static int cs2cs_emulation_setup(PJ *P) {
/* We ignore helmert if we have grid shift */
p = P->hgridshift ? nullptr : pj_param_exists(P->params, "towgs84");
while (p) {
char *def;
char *s = p->param;
double *d = P->datum_params;
size_t n = strlen(s);
const char *const s = p->param;
const double *const d = P->datum_params;

/* We ignore null helmert shifts (common in auto-translated resource
* files, e.g. epsg) */
Expand All @@ -938,19 +936,17 @@ static int cs2cs_emulation_setup(PJ *P) {
break;
}

const size_t n = strlen(s);
if (n <= 8) /* 8==strlen ("towgs84=") */
return 0;

size_t def_size = 100 + n;
def = static_cast<char *>(malloc(def_size));
if (nullptr == def)
return 0;
snprintf(def, def_size,
"break_cs2cs_recursion proj=helmert exact %s "
"convention=position_vector",
s);
Q = pj_create_internal(P->ctx, def);
free(def);
const size_t def_max_size = 100 + n;
std::string def;
def.reserve(def_max_size);
def += "break_cs2cs_recursion proj=helmert exact ";
def += s;
def += " convention=position_vector";
Q = pj_create_internal(P->ctx, def.c_str());
if (nullptr == Q)
return 0;
pj_inherit_ellipsoid_def(P, Q);
Expand Down

0 comments on commit b132ad6

Please sign in to comment.