Skip to content

Commit 0345835

Browse files
author
deadlightreal
committed
Forgot to remove fprintf in internal functions
1 parent 58319b1 commit 0345835

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

src/internal/datatype_allocator.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ struct SwiftNetMemoryAllocator allocator_create(const uint32_t item_size, const
5858
void* const stack_allocated_memory = malloc(chunk_item_amount * sizeof(void*));
5959

6060
if (unlikely(allocated_memory == NULL || stack_allocated_memory == NULL)) {
61-
fprintf(stderr, "Failed to allocate memory\n");
61+
PRINT_ERROR("Failed to allocate memory");
6262
exit(EXIT_FAILURE);
6363
}
6464

6565
struct SwiftNetMemoryAllocatorStack* const first_stack_pointers = malloc(sizeof(struct SwiftNetMemoryAllocatorStack));
6666
if (unlikely(first_stack_pointers == NULL)) {
67-
fprintf(stderr, "Failed to allocate memory\n");
67+
PRINT_ERROR("Failed to allocate memory");
6868
exit(EXIT_FAILURE);
6969
}
7070

@@ -76,7 +76,7 @@ struct SwiftNetMemoryAllocator allocator_create(const uint32_t item_size, const
7676

7777
struct SwiftNetMemoryAllocatorStack* const first_stack_data = malloc(sizeof(struct SwiftNetMemoryAllocatorStack));
7878
if (unlikely(first_stack_data == NULL)) {
79-
fprintf(stderr, "Failed to allocate memory\n");
79+
PRINT_ERROR("Failed to allocate memory");
8080
exit(EXIT_FAILURE);
8181
}
8282

@@ -124,13 +124,13 @@ static void create_new_stack(struct SwiftNetMemoryAllocator* const memory_alloca
124124
void* const allocated_memory = malloc(memory_allocator->item_size * chunk_item_amount);
125125
void* const stack_allocated_memory = malloc(chunk_item_amount * sizeof(void*));
126126
if (unlikely(allocated_memory == NULL || stack_allocated_memory == NULL)) {
127-
fprintf(stderr, "Failed to allocate memory\n");
127+
PRINT_ERROR("Failed to allocate memory");
128128
exit(EXIT_FAILURE);
129129
}
130130

131131
struct SwiftNetMemoryAllocatorStack* const stack_pointers = malloc(sizeof(struct SwiftNetMemoryAllocatorStack));
132132
if (unlikely(stack_pointers == NULL)) {
133-
fprintf(stderr, "Failed to allocate memory\n");
133+
PRINT_ERROR("Failed to allocate memory");
134134
exit(EXIT_FAILURE);
135135
}
136136

@@ -142,7 +142,7 @@ static void create_new_stack(struct SwiftNetMemoryAllocator* const memory_alloca
142142

143143
struct SwiftNetMemoryAllocatorStack* const stack_data = malloc(sizeof(struct SwiftNetMemoryAllocatorStack));
144144
if (unlikely(stack_data == NULL)) {
145-
fprintf(stderr, "Failed to allocate memory\n");
145+
PRINT_ERROR("Failed to allocate memory");
146146
exit(EXIT_FAILURE);
147147
}
148148

@@ -204,7 +204,7 @@ void allocator_free(struct SwiftNetMemoryAllocator* const memory_allocator, void
204204
const bool already_free = is_already_free(memory_allocator, memory_location);
205205

206206
if (already_free == true) {
207-
fprintf(stderr, "Pointer %p has already been freed\n", memory_location);
207+
PRINT_ERROR("Pointer %p has already been freed", memory_location);
208208
exit(EXIT_FAILURE);
209209
}
210210
#endif

src/internal/datatype_vector.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void vector_unlock(struct SwiftNetVector* const vector) {
1616
struct SwiftNetVector vector_create(const uint32_t starting_amount) {
1717
void* const data_ptr = malloc(sizeof(void*) * starting_amount);
1818
if (unlikely(data_ptr == NULL)) {
19-
fprintf(stderr, "Failed to malloc\n");
19+
PRINT_ERROR("Failed to malloc");
2020
exit(EXIT_FAILURE);
2121
}
2222

@@ -45,7 +45,7 @@ void vector_push(struct SwiftNetVector* const vector, void* const data) {
4545

4646
void** const new_data_ptr = realloc(vector->data, sizeof(void*) * new_capacity);
4747
if (unlikely(new_data_ptr == NULL)) {
48-
fprintf(stderr, "Failed to malloc\n");
48+
PRINT_ERROR("Failed to malloc");
4949
exit(EXIT_FAILURE);
5050
}
5151

src/internal/get_default_interface_and_mac.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int get_default_interface_and_mac(char* restrict interface_name, uint32_t interf
5858
}
5959

6060
if (!match) {
61-
fprintf(stderr, "No matching interface found for IP %s\n", local_ip);
61+
PRINT_ERROR("No matching interface found for IP %s", local_ip);
6262
freeifaddrs(ifaddr);
6363
return -1;
6464
}
@@ -96,7 +96,7 @@ int get_default_interface_and_mac(char* restrict interface_name, uint32_t interf
9696
freeifaddrs(ifaddr);
9797

9898
if (!mac_found) {
99-
fprintf(stderr, "No MAC address found for interface %s\n", interface_name);
99+
PRINT_ERROR("No MAC address found for interface %s", interface_name);
100100
return -1;
101101
}
102102

src/internal/get_mtu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const uint32_t get_mtu(const char* const restrict interface, const int sockfd) {
1616
strncpy(ifr.ifr_name, interface, IFNAMSIZ - 1);
1717

1818
if (ioctl(sockfd, SIOCGIFMTU, &ifr) < 0) {
19-
fprintf(stderr, "ioctl failed\n");
19+
PRINT_ERROR("ioctl failed");
2020
exit(EXIT_FAILURE);
2121
}
2222

src/internal/pcap_open.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pcap_t* swiftnet_pcap_open(const char* interface) {
1212
);
1313

1414
if (!p) {
15-
fprintf(stderr, "pcap_open_live failed: %s\n", errbuf);
15+
PRINT_ERROR("pcap_open_live failed: %s", errbuf);
1616
return NULL;
1717
}
1818

@@ -21,12 +21,12 @@ pcap_t* swiftnet_pcap_open(const char* interface) {
2121
bpf_u_int32 net = 0;
2222

2323
if (pcap_compile(p, &fp, filter_exp, 0, net) == -1) {
24-
fprintf(stderr, "Couldn't parse filter %s: %s\n", filter_exp, pcap_geterr(p));
24+
PRINT_ERROR("Couldn't parse filter %s: %s", filter_exp, pcap_geterr(p));
2525
exit(EXIT_FAILURE);
2626
}
2727

2828
if (pcap_setfilter(p, &fp) != 0) {
29-
fprintf(stderr, "Unable to set filter: %s\n", pcap_geterr(p));
29+
PRINT_ERROR("Unable to set filter: %s", pcap_geterr(p));
3030
}
3131

3232
return p;

src/internal/pcap_send.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
int swiftnet_pcap_send(pcap_t *pcap, const u_char *data, int len) {
44
if (pcap_inject(pcap, data, len) == -1) {
5-
fprintf(stderr, "inject error: %s\n", pcap_geterr(pcap));
5+
PRINT_ERROR("inject error: %s", pcap_geterr(pcap));
66
return -1;
77
}
88

0 commit comments

Comments
 (0)