Skip to content

Commit 948a0cc

Browse files
author
Dale Alleshouse
committed
a few lint fixes
1 parent 5e29e01 commit 948a0cc

19 files changed

+87
-101
lines changed

src/hashing/farmhash.c

100644100755
File mode changed.

src/list_data_structures/algo_timer.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#include "./algo_timer.h"
23

34
#include <stdint.h>

src/list_data_structures/algo_timer.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#pragma once
23

34
#include <inttypes.h>

src/list_data_structures/algo_timer_tests.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#include <stdbool.h>
23
#include <stdlib.h>
34

src/list_data_structures/array.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#include "./array.h"
23

34
#include <stdlib.h>

src/list_data_structures/array.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#pragma once
23

34
#include <stddef.h>

src/list_data_structures/binary_tree.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#include "./binary_tree.h"
23

34
#include <stdint.h>

src/list_data_structures/binary_tree.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#pragma once
23

34
#include <stddef.h>

src/list_data_structures/binary_tree_test.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#include "./binary_tree.h"
23

34
#include <limits.h>

src/list_data_structures/linked_list.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#include "./linked_list.h"
23

34
#include <stdlib.h>
@@ -231,7 +232,7 @@ void LinkedList_Destroy(LinkedList* list) {
231232
curr = curr->next;
232233

233234
LinkedList_ItemDestroy(list, doomed);
234-
};
235+
}
235236

236237
free(list);
237238
}

src/list_data_structures/linked_list.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
/*******************************************************************************
23
* This is a rather anomalous implementation because it's rarely the case that
34
* anyone would want to insert/delete an item into a linked list at a particular

src/list_data_structures/linked_list_tests.c

100644100755
+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#include <stdbool.h>
23
#include <stdlib.h>
34

@@ -25,9 +26,9 @@ static void ListIsValid(const LinkedList* list, const size_t n,
2526

2627
LinkedListItem* item = list->head;
2728
for (size_t i = 0; i < n; i++) {
28-
if (item == NULL || item->payload == NULL)
29+
if (item == NULL || item->payload == NULL) {
2930
CU_FAIL("null item")
30-
else {
31+
} else {
3132
CU_ASSERT_PTR_EQUAL(item->payload, expected[i]);
3233
item = item->next;
3334
}
@@ -36,9 +37,9 @@ static void ListIsValid(const LinkedList* list, const size_t n,
3637

3738
item = list->tail;
3839
for (size_t i = 1; i <= n; i++) {
39-
if (item == NULL || item->payload == NULL)
40+
if (item == NULL || item->payload == NULL) {
4041
CU_FAIL("null item")
41-
else {
42+
} else {
4243
CU_ASSERT_PTR_EQUAL(item->payload, expected[n - i]);
4344
item = item->prev;
4445
}

src/list_data_structures/list_operations.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#include "./list_operations.h"
23

34
#include <stdint.h>

src/list_data_structures/list_operations.h

100644100755
+8-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#pragma once
23

34
#include <stddef.h>
@@ -7,13 +8,13 @@
78

89
const size_t RANK_ERROR;
910

10-
#define LIST_ERROR(list_type, result) \
11-
{ \
12-
char str[1000]; \
13-
sprintf(str, "%s Error: %s, %s, %s, %d\n", list_type, \
14-
ListOp_ErrorMessage(result), __FILE__, __FUNCTION__, __LINE__); \
15-
\
16-
ErrorReporter_Report(result, str); \
11+
#define LIST_ERROR(list_type, result) \
12+
{ \
13+
char str[1000]; \
14+
snprintf(str, sizeof(str), "%s Error: %s, %s, %s, %d\n", list_type, \
15+
ListOp_ErrorMessage(result), __FILE__, __FUNCTION__, __LINE__); \
16+
\
17+
ErrorReporter_Report(result, str); \
1718
}
1819

1920
typedef void (*item_handler)(void* x);

src/list_data_structures/sorted_array.c

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#include "./sorted_array.h"
23

34
#include <stdio.h>

src/list_data_structures/sorted_array.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2020 Dale Alleshouse
12
#pragma once
23

34
#include "./array.h"

src/list_data_structures/sorted_array_test.c

100644100755
+4-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414

1515
typedef void* (*SortedArrayOp)(const Array*, const void*);
1616
typedef void* (*SortedArrayOpUnary)(const Array*);
17+
static unsigned int seed;
1718

1819
static Array* CreateSut(size_t n) {
1920
Array* sut = Array_Create(PIntComparator, sizeof(int));
2021
sut->array = calloc(sizeof(int), n);
2122

22-
for (size_t i = 0; i < n; i++) ((int*)sut->array)[i] = rand();
23+
for (size_t i = 0; i < n; i++) ((int*)sut->array)[i] = rand_r(&seed);
2324

2425
qsort(sut->array, n, sizeof(int), PIntComparator);
2526
sut->n = n;
@@ -326,6 +327,8 @@ static void SortedArray_Rank_standard() {
326327
}
327328

328329
int RegisterSortedArrayTests() {
330+
seed = time(NULL);
331+
329332
CU_TestInfo Common_tests[] = {CU_TEST_INFO(SortedArray_null_parameter),
330333
CU_TEST_INFO_NULL};
331334

src/test_runner.c

100644100755
+55-87
Original file line numberDiff line numberDiff line change
@@ -98,93 +98,61 @@ extern int RegisterMultiplySquareMatricesTests();
9898
extern int RegisterQuickSelectPartitionTests();
9999

100100
int RegisterTests() {
101-
return (RegisterGraphTests() != 0 + RegisterOverflowTests() !=
102-
0 + RegisterMathTests() !=
103-
0 +
104-
105-
RegisterCommonTests() !=
106-
0 +
107-
108-
RegisterGraphSearchTests() !=
109-
0 +
110-
111-
RegisterQueueTests() !=
112-
0 + RegisterPriorityQueueTests() != 0 + RegisterStackTests() !=
113-
0 + RegisterHeapTests() != 0 + RegisterHashTableTests() !=
114-
0 + RegisterBloomFilterTests() != 0 + RegisterHashFunctionTests() !=
115-
0 + RegisterDisjointSetTests() !=
116-
0 +
117-
118-
RegisterKnapsackProblemTests() !=
119-
0 +
120-
121-
RegisterRunningMedianTests() !=
122-
0 +
123-
124-
RegisterSequenceAlignmentTests() !=
125-
0 +
126-
127-
RegisterDijkstraTests() !=
128-
0 + RegisterShortestPathTests() != 0 + RegisterBellmanFordTests() !=
129-
0 + RegisterFloydWarshallTests() !=
130-
0 +
131-
132-
RegisterHuffmanCodeTests() !=
133-
0 +
134-
135-
RegisterLinkedListTests() !=
136-
0 + RegisterArrayTests() != 0 + RegisterAlgoTimerTests() !=
137-
0 + RegisterSortedArrayTests() != 0 + RegisterBinaryTreeTests() !=
138-
0 +
139-
140-
RegisterGraphTests() !=
141-
0 + RegisterMinCutTests() !=
142-
0 +
143-
144-
RegisterSatisfiabilityTests() !=
145-
0 +
146-
147-
RegisterQuickSortTests() !=
148-
0 + RegisterPartitionTests() != 0 + RegisterBubbleSortTests() !=
149-
0 + RegisterInsertionSortTests() !=
150-
0 + RegisterSelectionSortTests() !=
151-
0 + RegisterMergeSortTestTests() !=
152-
0 +
153-
154-
RegisterTravelingSalesmanTests() !=
155-
0 +
156-
157-
RegisterWeightedIndependentSetTests() !=
158-
0 +
159-
160-
RegisterMallocTestWrapperTests() !=
161-
0 +
162-
163-
RegisterMinSpanningTreeTests() !=
164-
0 + RegisterKruskalClusterTests() !=
165-
0 +
166-
167-
RegisterEuclidDistTests() !=
168-
0 + RegisterClosestDistanceTests() !=
169-
0 + RegisterClosestDistanceSlowTests() !=
170-
0 +
171-
172-
RegisterSelectTests() !=
173-
0 + RegisterQuickSelectTests() != 0 + RegisterPartitionTests() !=
174-
0 +
175-
176-
RegisterInversionCountTests() !=
177-
0 +
178-
179-
RegisterIsPowerOfTwoTests() !=
180-
0 + RegisterMultiplySquareMatricesTests() !=
181-
0 +
182-
183-
RegisterQuickSelectPartitionTests() !=
184-
0
185-
186-
) *
187-
-1;
101+
return (
102+
// clang-format off
103+
RegisterGraphTests() != 0 +
104+
RegisterOverflowTests() != 0 +
105+
RegisterMathTests() != 0 +
106+
RegisterCommonTests() != 0 +
107+
RegisterGraphSearchTests() != 0 +
108+
RegisterQueueTests() != 0 +
109+
RegisterPriorityQueueTests() != 0 +
110+
RegisterStackTests() != 0 +
111+
RegisterHeapTests() != 0 +
112+
RegisterHashTableTests() != 0 +
113+
RegisterBloomFilterTests() != 0 +
114+
RegisterHashFunctionTests() != 0 +
115+
RegisterDisjointSetTests() != 0 +
116+
RegisterKnapsackProblemTests() != 0 +
117+
RegisterRunningMedianTests() != 0 +
118+
RegisterSequenceAlignmentTests() != 0 +
119+
RegisterDijkstraTests() != 0 +
120+
RegisterShortestPathTests() != 0 +
121+
RegisterBellmanFordTests() != 0 +
122+
RegisterFloydWarshallTests() != 0 +
123+
RegisterHuffmanCodeTests() != 0 +
124+
RegisterLinkedListTests() != 0 +
125+
RegisterArrayTests() != 0 +
126+
RegisterAlgoTimerTests() != 0 +
127+
RegisterSortedArrayTests() != 0 +
128+
RegisterBinaryTreeTests() != 0 +
129+
RegisterGraphTests() != 0 +
130+
RegisterMinCutTests() != 0 +
131+
RegisterSatisfiabilityTests() != 0 +
132+
RegisterQuickSortTests() != 0 +
133+
RegisterPartitionTests() != 0 +
134+
RegisterBubbleSortTests() != 0 +
135+
RegisterInsertionSortTests() != 0 +
136+
RegisterSelectionSortTests() != 0 +
137+
RegisterMergeSortTestTests() != 0 +
138+
RegisterTravelingSalesmanTests() != 0 +
139+
RegisterWeightedIndependentSetTests() != 0 +
140+
RegisterMallocTestWrapperTests() != 0 +
141+
RegisterMinSpanningTreeTests() != 0 +
142+
RegisterKruskalClusterTests() != 0 +
143+
RegisterEuclidDistTests() != 0 +
144+
RegisterClosestDistanceTests() != 0 +
145+
RegisterClosestDistanceSlowTests() != 0 +
146+
RegisterSelectTests() != 0 +
147+
RegisterQuickSelectTests() != 0 +
148+
RegisterPartitionTests() != 0 +
149+
RegisterInversionCountTests() != 0 +
150+
RegisterIsPowerOfTwoTests() != 0 +
151+
RegisterMultiplySquareMatricesTests() != 0 +
152+
RegisterQuickSelectPartitionTests() != 0
153+
) *
154+
-1;
155+
// clang-format on
188156
}
189157

190158
int TestRunner(int (*register_tests)()) {

watch.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
inotify-hookable -q -w ./ -C "\.[ch]$=make $1 --jobs=8"
3+
inotify-hookable -q -w ./ -C "\.[ch]$=$1"

0 commit comments

Comments
 (0)