From 378755e083a77039cd5692b70f0c677cc22b331d Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Fri, 4 Oct 2024 11:19:10 +0100 Subject: [PATCH] CalmaRdpt.c: simplfy use of sprintf() This replacement pattern is easier to reason about and less error prone. --- calma/CalmaRdpt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/calma/CalmaRdpt.c b/calma/CalmaRdpt.c index 6a6abb91..fa891d2b 100644 --- a/calma/CalmaRdpt.c +++ b/calma/CalmaRdpt.c @@ -257,13 +257,13 @@ calmaElementBoundary(void) if ((CalmaSubcellPolygons != CALMA_POLYGON_NONE) && (calmaNonManhattan > 0)) { /* Place the polygon in its own subcell */ - char newname[] = "polygonXXXXX"; + char newname[16]; HashEntry *he; savedef = cifReadCellDef; /* Make up name for cell */ - sprintf(newname + 7, "%05d", ++CalmaPolygonCount); + snprintf(newname, sizeof(newname), "polygon%05d", ++CalmaPolygonCount); he = HashFind(&calmaDefInitHash, newname); if (!HashGetValue(he)) @@ -663,13 +663,13 @@ calmaElementPath(void) if (CalmaSubcellPaths) { /* Place the path in its own subcell */ - char newname[] = "pathXXXXX"; + char newname[16]; HashEntry *he; savedef = cifReadCellDef; /* Make up name for cell */ - sprintf(newname + 4, "%05d", ++CalmaPathCount); + snprintf(newname, sizeof(newname), "path%05d", ++CalmaPathCount); he = HashFind(&calmaDefInitHash, newname); if (!HashGetValue(he))