prevent unneeded memset
This commit is contained in:
parent
5acf0e6422
commit
2af29378bf
2 changed files with 9 additions and 7 deletions
2
Makefile
2
Makefile
|
@ -1,7 +1,7 @@
|
||||||
CC?=gcc
|
CC?=gcc
|
||||||
|
|
||||||
CFLAGS_DEV=-DJB_PRESET_DEBUG -ggdb -fsanitize=address -Og
|
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
|
CFLAGS+=-pipe -Wall -Wextra -Wshadow -pedantic -std=c99
|
||||||
|
|
||||||
|
|
14
server.c
14
server.c
|
@ -379,7 +379,7 @@ int bus_broadcast_signal(Bus *s, BusClient *client, WireCtx *ctx, WireMsg *msg)
|
||||||
return 0;
|
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));
|
BusClient *target = TRYPTR(bus_name_find_client(s, target_name));
|
||||||
struct iovec bufs[2] = {0};
|
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 (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");
|
_process_message_reply_error("xyz.hippoz.jitterbug.UnicastFailed");
|
||||||
goto end_nonfatal;
|
goto end_nonfatal;
|
||||||
}
|
}
|
||||||
|
@ -823,7 +823,7 @@ int bus_client_drain_messages(Bus *s, BusClient *client, uint8_t *data, uint32_t
|
||||||
return 0;
|
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)
|
int bus_turn(Bus *s)
|
||||||
{
|
{
|
||||||
static const char agree_unix_fd[] = "ERROR\r\n";
|
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]);
|
bus_client_remove(s, &s->clients[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (unlikely(bytes + 1 >= data_buffer_len)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
data[bytes] = '\0';
|
||||||
|
|
||||||
VERBOSE("\nrecv: got %zd bytes\n", bytes);
|
VERBOSE("\nrecv: got %zd bytes\n", bytes);
|
||||||
|
|
||||||
|
@ -941,9 +946,6 @@ int bus_turn(Bus *s)
|
||||||
_client_die("bad state");
|
_client_die("bad state");
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
|
||||||
memset(data, 0, bytes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue