Permalink
Browse files

AVRO-1164. C: Fix valgrind warnings in avro_test_schema

Contributed by Vivek Nadkarni.


git-svn-id: https://svn.apache.org/repos/asf/avro/trunk@1386903 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
dcreager committed Sep 17, 2012
1 parent cc6dce5 commit 5f19b060591af1de2b09487ff464bea8bf0b498e
Showing with 8 additions and 2 deletions.
  1. +3 −0 CHANGES.txt
  2. +5 −2 lang/c/tests/test_avro_schema.c
View
@@ -83,6 +83,9 @@ Avro 1.7.2 (unreleased)
AVRO-1150. Java: Fix tests to create all temporary files in target
directories. (Gabriel Reid via cutting)
+ AVRO-1164. C: Clean up valgrind warnings in test_avro_schema test case.
+ (Vivek Nadkarni via dcreager)
+
Avro 1.7.1 (16 July 2012)
NEW FEATURES
@@ -33,7 +33,7 @@ avro_writer_t avro_stderr;
static void run_tests(char *dirpath, int should_pass)
{
char jsontext[4096];
- size_t jsonlen, rval;
+ size_t rval;
char filepath[1024];
DIR *dir;
struct dirent *dent;
@@ -57,13 +57,13 @@ static void run_tests(char *dirpath, int should_pass)
snprintf(filepath, sizeof(filepath), "%s/%s", dirpath,
dent->d_name);
fprintf(stderr, "TEST %s...", filepath);
- jsonlen = 0;
fp = fopen(filepath, "r");
if (!fp) {
fprintf(stderr, "can't open!\n");
exit(EXIT_FAILURE);
}
rval = fread(jsontext, 1, sizeof(jsontext) - 1, fp);
+ fclose(fp);
jsontext[rval] = '\0';
test_rval =
avro_schema_from_json(jsontext, 0, &schema, NULL);
@@ -104,6 +104,7 @@ static void run_tests(char *dirpath, int should_pass)
}
}
while (dent != NULL);
+ closedir(dir);
}
static int test_array(void)
@@ -164,6 +165,8 @@ static int test_fixed(void)
fprintf(stderr, "Unexpected fixed size\n");
exit(EXIT_FAILURE);
}
+
+ avro_schema_decref(schema);
return 0;
}

0 comments on commit 5f19b06

Please sign in to comment.