Skip to content

Commit b008504

Browse files
committed
chore: Cleanup for Clang-Tidy notices
1 parent 00e6266 commit b008504

28 files changed

+446
-812
lines changed

tests/criterion/ecma402/calendar_test.c

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66

77
Test(TEST_SUITE, availableCanonicalCalendarsIsSorted)
88
{
9-
const char **calendars;
10-
int calendarsLength;
11-
12-
calendars = malloc(sizeof(char *) * ECMA402_CALENDAR_CAPACITY);
13-
calendarsLength = ecma402_availableCanonicalCalendars(calendars);
9+
const char **calendars = (const char **)malloc(sizeof(char *) * ECMA402_CALENDAR_CAPACITY);
10+
const int calendarsLength = ecma402_availableCanonicalCalendars(calendars);
1411

1512
cr_expect(gt(int, calendarsLength, 0));
1613

@@ -22,16 +19,13 @@ Test(TEST_SUITE, availableCanonicalCalendarsIsSorted)
2219
previous = calendars[i];
2320
}
2421

25-
free(calendars);
22+
free((void *)calendars);
2623
}
2724

2825
Test(TEST_SUITE, availableCanonicalCalendarsReturnsOnlyBcp47Values)
2926
{
30-
const char **calendars;
31-
int calendarsLength;
32-
33-
calendars = malloc(sizeof(char *) * ECMA402_CALENDAR_CAPACITY);
34-
calendarsLength = ecma402_availableCanonicalCalendars(calendars);
27+
const char **calendars = (const char **)malloc(sizeof(char *) * ECMA402_CALENDAR_CAPACITY);
28+
const int calendarsLength = ecma402_availableCanonicalCalendars(calendars);
3529

3630
cr_expect(gt(int, calendarsLength, 0));
3731

@@ -41,23 +35,19 @@ Test(TEST_SUITE, availableCanonicalCalendarsReturnsOnlyBcp47Values)
4135
cr_expect(ne(str, (char *)calendars[i], "islamicc"));
4236
}
4337

44-
free(calendars);
38+
free((void *)calendars);
4539
}
4640

4741
Test(TEST_SUITE, calendarsOfLocaleReturnsPreferredCalendar)
4842
{
49-
ecma402_locale *locale;
50-
const char **calendars;
51-
int calendarsLength;
52-
53-
locale = ecma402_initLocale("en-US-u-ca-buddhist");
54-
calendars = (const char **)malloc(sizeof(char *) * ECMA402_LOCALE_CALENDAR_CAPACITY);
55-
calendarsLength = ecma402_calendarsOfLocale(locale, calendars);
43+
ecma402_locale *locale = ecma402_initLocale("en-US-u-ca-buddhist");
44+
const char **calendars = (const char **)malloc(sizeof(char *) * ECMA402_LOCALE_CALENDAR_CAPACITY);
45+
const int calendarsLength = ecma402_calendarsOfLocale(locale, calendars);
5646

5747
cr_assert(eq(int, calendarsLength, 1));
5848
cr_expect(eq(str, (char *)calendars[0], "buddhist"));
5949

60-
free(calendars);
50+
free((void *)calendars);
6151
ecma402_freeLocale(locale);
6252
}
6353

@@ -73,7 +63,7 @@ Test(TEST_SUITE, calendarsOfLocaleReturnsExpectedCalendars)
7363
calendarsLength = ecma402_calendarsOfLocale(locale, calendars);
7464
cr_assert(eq(int, calendarsLength, 1));
7565
cr_expect(eq(str, (char *)calendars[0], "gregory"));
76-
free(calendars);
66+
free((void *)calendars);
7767
ecma402_freeLocale(locale);
7868

7969
// "und" has calendars of ["gregory"]
@@ -82,7 +72,7 @@ Test(TEST_SUITE, calendarsOfLocaleReturnsExpectedCalendars)
8272
calendarsLength = ecma402_calendarsOfLocale(locale, calendars);
8373
cr_assert(eq(int, calendarsLength, 1));
8474
cr_expect(eq(str, (char *)calendars[0], "gregory"));
85-
free(calendars);
75+
free((void *)calendars);
8676
ecma402_freeLocale(locale);
8777

8878
// "zh" has calendars of ["gregory", "chinese"]
@@ -92,7 +82,7 @@ Test(TEST_SUITE, calendarsOfLocaleReturnsExpectedCalendars)
9282
cr_assert(eq(int, calendarsLength, 2));
9383
cr_expect(eq(str, (char *)calendars[0], "gregory"));
9484
cr_expect(eq(str, (char *)calendars[1], "chinese"));
95-
free(calendars);
85+
free((void *)calendars);
9686
ecma402_freeLocale(locale);
9787

9888
// "jp" has calendars of ["gregory"]
@@ -101,7 +91,7 @@ Test(TEST_SUITE, calendarsOfLocaleReturnsExpectedCalendars)
10191
calendarsLength = ecma402_calendarsOfLocale(locale, calendars);
10292
cr_assert(eq(int, calendarsLength, 1));
10393
cr_expect(eq(str, (char *)calendars[0], "gregory"));
104-
free(calendars);
94+
free((void *)calendars);
10595
ecma402_freeLocale(locale);
10696

10797
// "jp-JP" has calendars of ["gregory", "japanese"]
@@ -111,7 +101,7 @@ Test(TEST_SUITE, calendarsOfLocaleReturnsExpectedCalendars)
111101
cr_assert(eq(int, calendarsLength, 2));
112102
cr_expect(eq(str, (char *)calendars[0], "gregory"));
113103
cr_expect(eq(str, (char *)calendars[1], "japanese"));
114-
free(calendars);
104+
free((void *)calendars);
115105
ecma402_freeLocale(locale);
116106

117107
// "und-Thai" has calendars of ["buddhist", "gregory"]
@@ -121,22 +111,18 @@ Test(TEST_SUITE, calendarsOfLocaleReturnsExpectedCalendars)
121111
cr_assert(eq(int, calendarsLength, 2));
122112
cr_expect(eq(str, (char *)calendars[0], "buddhist"));
123113
cr_expect(eq(str, (char *)calendars[1], "gregory"));
124-
free(calendars);
114+
free((void *)calendars);
125115
ecma402_freeLocale(locale);
126116
}
127117

128118
Test(TEST_SUITE, calendarsOfLocaleReturnsNoCalendarsForInvalidLocaleId)
129119
{
130-
ecma402_locale *locale;
131-
const char **calendars;
132-
int calendarsLength;
133-
134-
locale = ecma402_initLocale("foobar-baz");
135-
calendars = (const char **)malloc(sizeof(char *) * ECMA402_LOCALE_CALENDAR_CAPACITY);
136-
calendarsLength = ecma402_calendarsOfLocale(locale, calendars);
120+
ecma402_locale *locale = ecma402_initLocale("foobar-baz");
121+
const char **calendars = (const char **)malloc(sizeof(char *) * ECMA402_LOCALE_CALENDAR_CAPACITY);
122+
const int calendarsLength = ecma402_calendarsOfLocale(locale, calendars);
137123

138124
cr_assert(eq(int, calendarsLength, 0));
139125

140-
free(calendars);
126+
free((void *)calendars);
141127
ecma402_freeLocale(locale);
142128
}

tests/criterion/ecma402/category_test.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@
1313
#define CATEGORY_VALUES_TEST(name, category, capacity) \
1414
Test(TEST_SUITE, supportedValuesFor##name##Category) \
1515
{ \
16-
const char **values; \
17-
int count; \
18-
values = (const char **)malloc(sizeof(const char *) * capacity); \
19-
count = ecma402_supportedValuesForCategory(category, values); \
16+
const char **values = (const char **)malloc(sizeof(const char *) * capacity); \
17+
const int count = ecma402_supportedValuesForCategory(category, values); \
2018
cr_expect(values != NULL); \
2119
cr_expect(gt(int, count, 0)); \
22-
free(values); \
20+
free((void *)values); \
2321
}
2422

2523
#define CATEGORY_CAPACITY_TEST(name, category, expectedCapacity) \
2624
Test(TEST_SUITE, capacityFor##name##Category) \
2725
{ \
28-
int actualCapacity = ecma402_capacityForCategory(category); \
26+
const int actualCapacity = ecma402_capacityForCategory(category); \
2927
cr_assert(eq(int, actualCapacity, expectedCapacity)); \
3028
}
3129

@@ -44,13 +42,10 @@ CATEGORY_CAPACITY_TEST(Unit, ECMA402_CATEGORY_UNIT, ECMA402_UNIT_CAPACITY)
4442

4543
Test(TEST_SUITE, getsSupportedValuesForInvalidCategory)
4644
{
47-
const char **values;
48-
int count;
49-
50-
values = (const char **)malloc(sizeof(const char *) * 1);
51-
count = ecma402_supportedValuesForCategory("foo", values);
45+
const char **values = (const char **)malloc(sizeof(const char *) * 1);
46+
const int count = ecma402_supportedValuesForCategory("foo", values);
5247

5348
cr_expect(eq(int, count, 0));
5449

55-
free(values);
50+
free((void *)values);
5651
}

tests/criterion/ecma402/collation_test.c

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66

77
Test(TEST_SUITE, availableCanonicalCollationsDoesNotHaveSearchOrStandard)
88
{
9-
const char **collations;
10-
int collationsLength;
11-
12-
collations = malloc(sizeof(char *) * ECMA402_COLLATION_CAPACITY);
13-
collationsLength = ecma402_availableCanonicalCollations(collations);
9+
const char **collations = (const char **)malloc(sizeof(char *) * ECMA402_COLLATION_CAPACITY);
10+
const int collationsLength = ecma402_availableCanonicalCollations(collations);
1411

1512
cr_expect(gt(int, collationsLength, 0));
1613

@@ -21,16 +18,13 @@ Test(TEST_SUITE, availableCanonicalCollationsDoesNotHaveSearchOrStandard)
2118
cr_expect(ne(str, (char *)collations[i], ECMA402_COLLATION_STANDARD));
2219
}
2320

24-
free(collations);
21+
free((void *)collations);
2522
}
2623

2724
Test(TEST_SUITE, availableCanonicalCollationsIsSorted)
2825
{
29-
const char **collations;
30-
int collationsLength;
31-
32-
collations = malloc(sizeof(char *) * ECMA402_COLLATION_CAPACITY);
33-
collationsLength = ecma402_availableCanonicalCollations(collations);
26+
const char **collations = (const char **)malloc(sizeof(char *) * ECMA402_COLLATION_CAPACITY);
27+
const int collationsLength = ecma402_availableCanonicalCollations(collations);
3428

3529
cr_expect(gt(int, collationsLength, 0));
3630

@@ -42,16 +36,13 @@ Test(TEST_SUITE, availableCanonicalCollationsIsSorted)
4236
previous = collations[i];
4337
}
4438

45-
free(collations);
39+
free((void *)collations);
4640
}
4741

4842
Test(TEST_SUITE, availableCanonicalCollationsReturnsOnlyBcp47Values)
4943
{
50-
const char **collations;
51-
int collationsLength;
52-
53-
collations = malloc(sizeof(char *) * ECMA402_COLLATION_CAPACITY);
54-
collationsLength = ecma402_availableCanonicalCollations(collations);
44+
const char **collations = (const char **)malloc(sizeof(char *) * ECMA402_COLLATION_CAPACITY);
45+
const int collationsLength = ecma402_availableCanonicalCollations(collations);
5546

5647
cr_expect(gt(int, collationsLength, 0));
5748

@@ -62,39 +53,31 @@ Test(TEST_SUITE, availableCanonicalCollationsReturnsOnlyBcp47Values)
6253
cr_expect(ne(str, (char *)collations[i], "traditional"));
6354
}
6455

65-
free(collations);
56+
free((void *)collations);
6657
}
6758

6859
Test(TEST_SUITE, collationsOfLocaleReturnsPreferredCollation)
6960
{
70-
ecma402_locale *locale;
71-
const char **values;
72-
int valuesLength;
73-
74-
locale = ecma402_initLocale("en-US-u-co-phonebk");
75-
values = (const char **)malloc(sizeof(char *) * ECMA402_LOCALE_COLLATION_CAPACITY);
76-
valuesLength = ecma402_collationsOfLocale(locale, values);
61+
ecma402_locale *locale = ecma402_initLocale("en-US-u-co-phonebk");
62+
const char **values = (const char **)malloc(sizeof(char *) * ECMA402_LOCALE_COLLATION_CAPACITY);
63+
const int valuesLength = ecma402_collationsOfLocale(locale, values);
7764

7865
cr_assert(eq(int, valuesLength, 1));
7966
cr_expect(eq(str, (char *)values[0], "phonebk"));
8067

81-
free(values);
68+
free((void *)values);
8269
ecma402_freeLocale(locale);
8370
}
8471

8572
Test(TEST_SUITE, collationsOfLocaleReturnsNoCollationsForInvalidLocaleId)
8673
{
87-
ecma402_locale *locale;
88-
const char **values;
89-
int valuesLength;
90-
91-
locale = ecma402_initLocale("foobar-baz");
92-
values = (const char **)malloc(sizeof(char *) * ECMA402_LOCALE_COLLATION_CAPACITY);
93-
valuesLength = ecma402_collationsOfLocale(locale, values);
74+
ecma402_locale *locale = ecma402_initLocale("foobar-baz");
75+
const char **values = (const char **)malloc(sizeof(char *) * ECMA402_LOCALE_COLLATION_CAPACITY);
76+
const int valuesLength = ecma402_collationsOfLocale(locale, values);
9477

9578
cr_assert(eq(int, valuesLength, 0));
9679

97-
free(values);
80+
free((void *)values);
9881
ecma402_freeLocale(locale);
9982
}
10083

@@ -111,7 +94,7 @@ Test(TEST_SUITE, collationsOfLocaleReturnsExpectedCollations)
11194
cr_assert(eq(int, valuesLength, 2));
11295
cr_expect(eq(str, (char *)values[0], "emoji"));
11396
cr_expect(eq(str, (char *)values[1], "eor"));
114-
free(values);
97+
free((void *)values);
11598
ecma402_freeLocale(locale);
11699

117100
// "es-MX" has collations of ["trad", "emoji", "eor"]
@@ -122,6 +105,6 @@ Test(TEST_SUITE, collationsOfLocaleReturnsExpectedCollations)
122105
cr_expect(eq(str, (char *)values[0], "trad"));
123106
cr_expect(eq(str, (char *)values[1], "emoji"));
124107
cr_expect(eq(str, (char *)values[2], "eor"));
125-
free(values);
108+
free((void *)values);
126109
ecma402_freeLocale(locale);
127110
}

0 commit comments

Comments
 (0)