Skip to content

Commit

Permalink
[WIP] u_char to char manual fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
ac000 committed Aug 22, 2024
1 parent 6c3003e commit 4b82d97
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
6 changes: 6 additions & 0 deletions auto/cc/test
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ case $NXT_CC_NAME in
#NXT_CFLAGS="$NXT_CFLAGS -Wshorten-64-to-32"
NXT_CFLAGS="$NXT_CFLAGS -Wwrite-strings"

# OK due to -funsigned-char
NXT_CFLAGS="$NXT_CFLAGS -Wno-char-subscripts"

# -O2 enables -fstrict-aliasing and -fstrict-overflow.
#NXT_CFLAGS="$NXT_CFLAGS -O2"
NXT_CFLAGS="$NXT_CFLAGS -fno-strict-aliasing"
Expand Down Expand Up @@ -126,6 +129,9 @@ case $NXT_CC_NAME in
# strict-aliasing is always enabled by default in clang
NXT_CFLAGS="$NXT_CFLAGS -fno-strict-aliasing"

# OK due to -funsigned-char
NXT_CFLAGS="$NXT_CFLAGS -Wno-char-subscripts"

#NXT_CFLAGS="$NXT_CFLAGS -fomit-frame-pointer"
NXT_CFLAGS="$NXT_CFLAGS -Wstrict-overflow=5"

Expand Down
2 changes: 1 addition & 1 deletion src/nxt_main_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ nxt_main_start_process_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)

rt = task->thread->runtime;

app_conf->user.start = (u_char*)rt->user_cred.user;
app_conf->user.start = (char *)rt->user_cred.user;
app_conf->user.length = nxt_strlen(rt->user_cred.user);

ret = nxt_conf_map_object(process->mem_pool, conf, nxt_common_app_conf,
Expand Down
6 changes: 3 additions & 3 deletions src/nxt_mem_zone.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ static void *
nxt_mem_zone_alloc_small(nxt_mem_zone_t *zone, nxt_mem_zone_slot_t *slot,
size_t size)
{
char *p;
uint8_t *p;
uint8_t *map;
nxt_mem_zone_page_t *page;

Expand Down Expand Up @@ -822,7 +822,7 @@ static const char *
nxt_mem_zone_free_chunk(nxt_mem_zone_t *zone, nxt_mem_zone_page_t *page,
void *p)
{
char *map;
uint8_t *map;
uint32_t size, offset, chunk;
nxt_mem_zone_page_t *pg, **ppg;
nxt_mem_zone_slot_t *slot;
Expand All @@ -843,7 +843,7 @@ nxt_mem_zone_free_chunk(nxt_mem_zone_t *zone, nxt_mem_zone_page_t *page,

if (nxt_mem_zone_page_bitmap(zone, slot)) {
/* A page's chunks bitmap is placed at the start of the page. */
map = (char *) ((uintptr_t) p & ~((uintptr_t) zone->page_size_mask));
map = (uint8_t *) ((uintptr_t) p & ~((uintptr_t) zone->page_size_mask));

} else {
map = page->u.map;
Expand Down
11 changes: 6 additions & 5 deletions src/nxt_sockaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


#if (NXT_INET6)
static char *nxt_inet6_ntop(char *addr, char *buf, char *end);
static char *nxt_inet6_ntop(uint8_t *addr, char *buf, char *end);
#endif

static nxt_sockaddr_t *nxt_sockaddr_unix_parse(nxt_mp_t *mp, nxt_str_t *addr);
Expand Down Expand Up @@ -432,7 +432,7 @@ nxt_sockaddr_cmp(nxt_sockaddr_t *sa1, nxt_sockaddr_t *sa2)
#if (NXT_INET6)

static char *
nxt_inet6_ntop(char *addr, char *buf, char *end)
nxt_inet6_ntop(uint8_t *addr, char *buf, char *end)
{
char *p;
size_t zero_groups, last_zero_groups, ipv6_bytes;
Expand Down Expand Up @@ -823,7 +823,8 @@ nxt_inet_addr(char *buf, size_t length)
nxt_int_t
nxt_inet6_addr(struct in6_addr *in6_addr, char *buf, size_t length)
{
char c, *addr, *zero_start, *ipv4, *dst, *src, *end;
char c, *ipv4, *end;
uint8_t *addr, *zero_start, *src, *dst;
nxt_uint_t digit, group, nibbles, groups_left;

if (length == 0) {
Expand All @@ -850,8 +851,8 @@ nxt_inet6_addr(struct in6_addr *in6_addr, char *buf, size_t length)
if (nibbles != 0) {
ipv4 = buf;

*addr++ = (u_char) (group >> 8);
*addr++ = (u_char) (group & 0xFF);
*addr++ = (uint8_t) (group >> 8);
*addr++ = (uint8_t) (group & 0xFF);
groups_left--;

if (groups_left != 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/nxt_websocket_accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ nxt_websocket_base64_encode(char *d, const uint8_t *s, size_t len)
void
nxt_websocket_accept(char *accept, const void *key)
{
char bin_accept[20];
uint8_t bin_accept[20];
nxt_sha1_t ctx;
static const char accept_guid[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";

nxt_sha1_init(&ctx);
nxt_sha1_update(&ctx, key, 24);
nxt_sha1_update(&ctx, accept_guid, nxt_length(accept_guid));
nxt_sha1_final(bin_accept, &ctx);
nxt_sha1_final((char *)bin_accept, &ctx);

nxt_websocket_base64_encode(accept, bin_accept, sizeof(bin_accept));
}
Expand Down

0 comments on commit 4b82d97

Please sign in to comment.