summaryrefslogtreecommitdiffstats
path: root/ini/ini_valueobj_ut.c
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2012-12-23 13:49:56 -0500
committerOndrej Kos <okos@redhat.com>2013-01-24 08:34:40 +0100
commit833a46e384828be48c27898e755d6215eb5c4bb8 (patch)
treeeaf34cd463381efc40991151d41d9deec295f704 /ini/ini_valueobj_ut.c
parent57faa64667411a3d8eeeeff62b1e659a94ed29cf (diff)
downloadding-libs-833a46e384828be48c27898e755d6215eb5c4bb8.tar.gz
ding-libs-833a46e384828be48c27898e755d6215eb5c4bb8.tar.xz
ding-libs-833a46e384828be48c27898e755d6215eb5c4bb8.zip
Replacing sprintf with snprintf
Replaced sprintf in the unit test. Defined constants for sizes and used them. Wrpapped lines where noticed that they are longer than 80. Added comments to the places where sprintf is still used but it is safe to use.
Diffstat (limited to 'ini/ini_valueobj_ut.c')
-rw-r--r--ini/ini_valueobj_ut.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ini/ini_valueobj_ut.c b/ini/ini_valueobj_ut.c
index eb7937c..7911860 100644
--- a/ini/ini_valueobj_ut.c
+++ b/ini/ini_valueobj_ut.c
@@ -30,6 +30,8 @@
#define TRACE_HOME
#include "trace.h"
+#define TEST_SIZE 80
+
int verbose = 0;
#define VOOUT(foo) \
@@ -47,12 +49,12 @@ static int create_comment(int i, struct ini_comment **ic)
{
int error = EOK;
const char *template = ";Line 0 of the value %d";
- char comment[80];
+ char comment[TEST_SIZE];
struct ini_comment *new_ic = NULL;
TRACE_FLOW_ENTRY();
- sprintf(comment, template, i);
+ snprintf(comment, TEST_SIZE, template, i);
if ((error = ini_comment_create(&new_ic)) ||
@@ -579,7 +581,7 @@ int vo_copy_test(void)
}
/* Replace comment in the value */
- sprintf(comment, ";This is value with boundary %d", wrap);
+ snprintf(comment, TEST_SIZE, ";This is value with boundary %d", wrap);
VOOUT(printf("Comment: %s\n", comment));
error = ini_comment_replace(ic, 1, comment);
if (error) {