From 0951e1b7804dd571e1be3629531f4865d4c210d7 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Wed, 23 Jun 2010 18:21:38 +0200 Subject: [PATCH] niash: fix format string for gamma table debugging, slight rework Avoid calling strcpy()/strcat() unnecessarily, kill intermediate buffer. --- backend/niash.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/backend/niash.c b/backend/niash.c index 1b0ea49d5..7bc8a25b0 100644 --- a/backend/niash.c +++ b/backend/niash.c @@ -986,7 +986,6 @@ sane_control_option (SANE_Handle h, SANE_Int n, SANE_Action Action, TScanner *s; SANE_Bool fVal; static char szTable[100]; - char szTemp[16]; int *pi; int i; SANE_Int info; @@ -1111,21 +1110,18 @@ sane_control_option (SANE_Handle h, SANE_Int n, SANE_Action Action, { if ((SANE_GAMMA_SIZE / 16) && (i % (SANE_GAMMA_SIZE / 16)) == 0) { - strcat (szTable, "\n"); - DBG (DBG_MSG, szTable); - strcpy (szTable, ""); + DBG (DBG_MSG, "%s\n", szTable); + szTable[0] = '\0'; } /* test for number print */ if ((SANE_GAMMA_SIZE / 64) && (i % (SANE_GAMMA_SIZE / 64)) == 0) { - sprintf (szTemp, " %04X", pi[i]); - strcat (szTable, szTemp); + sprintf (szTable + strlen(szTable), " %04X", pi[i]); } } if (strlen (szTable)) { - strcat (szTable, "\n"); - DBG (DBG_MSG, szTable); + DBG (DBG_MSG, "%s\n", szTable); } break;