prevent unneeded memset

This commit is contained in:
hippoz 2023-01-22 17:03:30 +02:00
parent 5acf0e6422
commit 2af29378bf
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED
2 changed files with 9 additions and 7 deletions

View file

@ -1,7 +1,7 @@
CC?=gcc
CFLAGS_DEV=-DJB_PRESET_DEBUG -ggdb -fsanitize=address -Og
CFLAGS_RELEASE=-O2 -fgraphite-identity -funroll-loops -ftree-vectorize -flto
CFLAGS_RELEASE=-O2 -fgraphite-identity -funroll-loops -ftree-vectorize -flto -ggdb
CFLAGS+=-pipe -Wall -Wextra -Wshadow -pedantic -std=c99

View file

@ -379,7 +379,7 @@ int bus_broadcast_signal(Bus *s, BusClient *client, WireCtx *ctx, WireMsg *msg)
return 0;
}
int bus_unicast_message(Bus *s, WireMsg *msg, WireCtx *ctx, char *target_name, char *sender_unique_name, WireCtx *reply_ctx)
int bus_unicast_message(Bus *s, WireMsg *msg, WireCtx *ctx, char *target_name, char *sender_unique_name)
{
BusClient *target = TRYPTR(bus_name_find_client(s, target_name));
struct iovec bufs[2] = {0};
@ -765,7 +765,7 @@ int bus_client_process_message(Bus *s, BusClient *client, WireCtx *ctx)
}
if (destination_field->present) {
if (bus_unicast_message(s, &msg, ctx, destination_field->t.str, client->unique_name->name, &reply_ctx) < 0) {
if (bus_unicast_message(s, &msg, ctx, destination_field->t.str, client->unique_name->name) < 0) {
_process_message_reply_error("xyz.hippoz.jitterbug.UnicastFailed");
goto end_nonfatal;
}
@ -823,7 +823,7 @@ int bus_client_drain_messages(Bus *s, BusClient *client, uint8_t *data, uint32_t
return 0;
}
#define _client_die(m) do { bus_client_error(s, &s->clients[i], m); goto done; } while(0)
#define _client_die(m) do { bus_client_error(s, &s->clients[i], m); continue; } while(0)
int bus_turn(Bus *s)
{
static const char agree_unix_fd[] = "ERROR\r\n";
@ -880,6 +880,11 @@ int bus_turn(Bus *s)
bus_client_remove(s, &s->clients[i]);
continue;
}
if (unlikely(bytes + 1 >= data_buffer_len)) {
continue;
}
data[bytes] = '\0';
VERBOSE("\nrecv: got %zd bytes\n", bytes);
@ -941,9 +946,6 @@ int bus_turn(Bus *s)
_client_die("bad state");
} break;
}
done:
memset(data, 0, bytes);
}
}