fix compilation warnings with gcc 8

This commit is contained in:
Paul Gardner-Stephen 2020-07-10 09:28:02 +09:30
parent 338c9bed1f
commit 8231c7728a
15 changed files with 61 additions and 42 deletions

View File

@ -73,11 +73,12 @@ static size_t _base64_encodev(const char symbols[], char *dstBase64, const struc
if (place)
*dst++ = symbols[buf];
switch (place) {
case 1:
*dst++ = symbols[64];
FALLTHROUGH;
case 2:
*dst++ = symbols[64];
case 1:
*dst++ = symbols[64];
*dst++ = symbols[64];
break;
case 2:
*dst++ = symbols[64];
}
return dst - dstBase64;
}

View File

@ -120,7 +120,7 @@ static int add_record(int mdp_sockfd){
// TODO check that did is a valid phone number
char url[256];
char url[4096];
snprintf(url, sizeof(url), "sid://%s/local/%s|%s|%s", sid, did, did, name);
// TODO only add whitelisted entries

View File

@ -1212,8 +1212,9 @@ static int http_request_decode_chunks(struct http_request *r){
return WHY("Unexpected data");
return 0;
}
FALLTHROUGH;
}
FALLTHROUGH;
// fall through
case CHUNK_SIZE:{
const char *p;
// TODO fail on non hex input
@ -1240,8 +1241,9 @@ static int http_request_decode_chunks(struct http_request *r){
r->request_content_remaining = 0;
IDEBUGF(r->debug, "EOF Chunk");
}
FALLTHROUGH;
}
FALLTHROUGH;
// fall through
case CHUNK_DATA:{
// Skip over the chunk heading if we can, to avoid a memmove.
if (r->end_decoded == r->parsed)
@ -1531,7 +1533,8 @@ static int http_request_form_data_start_part(struct http_request *r, int b)
r->part_header.content_length
);
}
FALLTHROUGH;
_INVOKE_HANDLER_VOID(handle_mime_part_end);
break;
case HEADER:
_INVOKE_HANDLER_VOID(handle_mime_part_end);
break;
@ -1572,6 +1575,7 @@ static int http_request_parse_body_form_data(struct http_request *r)
at_start = 1;
r->form_data_state = PREAMBLE;
FALLTHROUGH;
// fall through
case PREAMBLE: {
DEBUGF(http_server, "PREAMBLE");
char *start = r->parsed;
@ -2165,7 +2169,8 @@ unsigned http_range_close(struct http_range *dst, const struct http_range *src,
switch (range->type) {
case CLOSED:
last = range->last < resource_length ? range->last : resource_length - 1;
FALLTHROUGH;
first = range->first < resource_length ? range->first : resource_length;
break;
case OPEN:
first = range->first < resource_length ? range->first : resource_length;
break;

View File

@ -177,7 +177,7 @@ static int restful_keyring_identitylist_json_content_chunk(struct http_request *
case LIST_ROWS:
strbuf_putc(b, ',');
FALLTHROUGH;
FALLTHROUGH; // fall through
case LIST_FIRST:
r->u.sidlist.phase = LIST_ROWS;
const char *did = NULL;

7
lang.h
View File

@ -78,10 +78,13 @@ typedef char bool_t;
// To suppress the "may fall through" warning from -Wimplicit-fallthrough.
#ifdef HAVE_STMT_ATTRIBUTE_FALLTHROUGH
# define __ATTRIBUTE_fallthrough __fallthrough__
# define FALLTHROUGH __attribute__((__fallthrough__))
# define FALLTHROUGH __attribute__((__fallthrough__));
#else
# define __ATTRIBUTE_fallthrough
# define FALLTHROUGH
// If there is no __fallthrough__ attribute, it is a bit of a pain, because
// not all version of GCC will let us define the fall-through comment in a macro
// like this for portability.
# define FALLTHROUGH // fall-through
#endif
#endif // __SERVAL_DNA__LANG_H

View File

@ -212,14 +212,14 @@ static int activity_ack(struct meshmb_feeds *feeds, struct message_ply_ack *ack)
case RHIZOME_BUNDLE_STATUS_NEW:
rhizome_manifest_set_tail(m, 0);
rhizome_manifest_set_filesize(m, 0);
FALLTHROUGH;
FALLTHROUGH; // fall through
case RHIZOME_BUNDLE_STATUS_SAME:
{
enum rhizome_payload_status pstatus = rhizome_write_open_journal(&feeds->ack_writer, m, 0, RHIZOME_SIZE_UNSET);
if (pstatus==RHIZOME_PAYLOAD_STATUS_NEW)
break;
}
FALLTHROUGH;
FALLTHROUGH; // fall through
case RHIZOME_BUNDLE_STATUS_BUSY:
rhizome_bundle_result_free(&result);
rhizome_manifest_free(m);

View File

@ -341,8 +341,7 @@ static int restful_meshmb_list_json_content_chunk(struct http_request *hr, strbu
return 1;
ROWS:
case LIST_ROWS: FALLTHROUGH;
case LIST_FIRST:
case LIST_ROWS: case LIST_FIRST:
if (!message_ply_is_open(&r->u.plylist.ply_reader)){
// re-load the current message text
@ -373,7 +372,7 @@ ROWS:
END:
r->u.plylist.phase = LIST_END;
FALLTHROUGH;
FALLTHROUGH; // fall through
case LIST_END:
{
@ -398,7 +397,7 @@ END:
strbuf_puts(b, "\n]\n}\n");
if (!strbuf_overrun(b))
r->u.plylist.phase = LIST_DONE;
FALLTHROUGH;
FALLTHROUGH; // fall through
case LIST_DONE:
return 0;
}
@ -603,8 +602,7 @@ static int restful_meshmb_feedlist_json_content_chunk(struct http_request *hr, s
r->u.meshmb_feeds.phase = LIST_ROWS;
return 1;
case LIST_ROWS: FALLTHROUGH;
case LIST_FIRST:
case LIST_ROWS: case LIST_FIRST:
{
struct enum_state state={
.request = r,
@ -617,12 +615,12 @@ static int restful_meshmb_feedlist_json_content_chunk(struct http_request *hr, s
return 0;
}
r->u.meshmb_feeds.phase = LIST_END;
FALLTHROUGH;
FALLTHROUGH; // fall through
case LIST_END:
strbuf_puts(b, "\n]\n}\n");
if (!strbuf_overrun(b))
r->u.plylist.phase = LIST_DONE;
FALLTHROUGH;
FALLTHROUGH; // fall through
case LIST_DONE:
return 0;
}

View File

@ -1496,7 +1496,7 @@ static void file_interface_init(const struct config_network_interface *ifconfig)
broadcast.inet.sin_port=htons(ifconfig->port);
broadcast.inet.sin_addr.s_addr=ifconfig->dummy_address.s_addr | ~ifconfig->dummy_netmask.s_addr;
FALLTHROUGH;
FALLTHROUGH; // fall through
case SOCK_STREAM:
if (!form_dummy_file_path(file_path, sizeof file_path, ifconfig->file))
return; // ignore if path is too long

View File

@ -1399,7 +1399,8 @@ struct rhizome_bundle_result rhizome_fill_manifest(rhizome_manifest *m, const ch
if (rhizome_manifest_createid(m) == -1) {
return rhizome_bundle_result_static(RHIZOME_BUNDLE_STATUS_ERROR, "Could not bind manifest to an ID");
}
FALLTHROUGH; // to set the BK field...
// to set the BK field...
FALLTHROUGH; // fall through
case NEW_BUNDLE_ID:
assert(m->has_id);
// If the manifest has no author but does have a 'sender' field, then use the

View File

@ -702,7 +702,7 @@ int _sqlite_vbind(struct __sourceloc __whence, int log_level, sqlite_retry_state
case SQLITE_LOCKED: \
if (retry && _sqlite_retry(__whence, retry, #FUNC "()")) \
continue; \
FALLTHROUGH; \
FALLTHROUGH; /* fall through */ \
default: \
LOGF(log_level, #FUNC "(%d) failed, %s: %s", index, sqlite3_errmsg(rhizome_database.db), sqlite3_sql(statement)); \
sqlite3_finalize(statement); \

View File

@ -585,7 +585,7 @@ static int insert_make_manifest(httpd_request *r)
break;
default:
WHYF("rhizome_manifest_parse() returned %d", n);
FALLTHROUGH;
FALLTHROUGH; // fall through
case -1:
r->bundle_result = rhizome_bundle_result_static(RHIZOME_BUNDLE_STATUS_ERROR, "Internal error while parsing manifest");
break;

View File

@ -430,7 +430,7 @@ static void sync_send_peer(struct subscriber *peer, struct rhizome_sync_keys *sy
DEBUGF(rhizome_sync_keys, "Can't send manifest right now, (hash %s) %s",
alloca_sync_key(&msg->key),
rhizome_bundle_status_message_nonnull(status));
FALLTHROUGH;
FALLTHROUGH; // fall through
case RHIZOME_BUNDLE_STATUS_NEW:
// TODO we don't have this bundle anymore!
ob_rewind(payload);

View File

@ -104,7 +104,7 @@ static int restful_route_list_json_content_chunk(struct http_request *hr, strbuf
case LIST_ROWS:
strbuf_putc(b, ',');
FALLTHROUGH;
FALLTHROUGH; // fall through
case LIST_FIRST:
r->u.subscriberlist.phase = LIST_ROWS;
struct subscriber **subscriberp = subscriber_iterator_get_current(&r->u.subscriberlist.it);

View File

@ -79,7 +79,9 @@ strbuf strbuf_uuid(strbuf sb, const serval_uuid_t *uuid)
switch (i) {
case 4: case 6: case 8: case 10:
strbuf_putc(sb, '-');
FALLTHROUGH;
strbuf_putc(sb, hexdigit_lower[uuid->u.binary[i] >> 4]);
strbuf_putc(sb, hexdigit_lower[uuid->u.binary[i] & 0xf]);
break;
default:
strbuf_putc(sb, hexdigit_lower[uuid->u.binary[i] >> 4]);
strbuf_putc(sb, hexdigit_lower[uuid->u.binary[i] & 0xf]);

View File

@ -494,19 +494,28 @@ strbuf strbuf_append_sockaddr(strbuf sb, const struct sockaddr *addr, socklen_t
}
break;
case AF_INET: FALLTHROUGH;
case AF_INET6:{
char name[INET6_ADDRSTRLEN];
char service[6];
if (getnameinfo(addr, addrlen, name, sizeof name, service, sizeof service, NI_NUMERICHOST|NI_NUMERICSERV)==0){
strbuf_sprintf(sb, "%s:%s:%s",
addr->sa_family==AF_INET?"AF_INET":"AF_INET6",
name,
service);
break;
case AF_INET6:
{
char name[INET6_ADDRSTRLEN];
char service[6];
if (getnameinfo(addr, addrlen, name, sizeof name, service, sizeof service, NI_NUMERICHOST|NI_NUMERICSERV)==0){
strbuf_sprintf(sb, "%s:%s:%s",
addr->sa_family==AF_INET?"AF_INET":"AF_INET6",
name,
service);
break;
}
strbuf_append_socket_domain(sb, addr->sa_family);
size_t len = (size_t)addrlen > sizeof addr->sa_family ? addrlen - sizeof addr->sa_family : 0;
unsigned i;
for (i = 0; i < len; ++i) {
strbuf_putc(sb, i ? ',' : ':');
strbuf_sprintf(sb, "%02x", addr->sa_data[i]);
}
}
FALLTHROUGH;
}
break;
default: {
strbuf_append_socket_domain(sb, addr->sa_family);
size_t len = (size_t)addrlen > sizeof addr->sa_family ? addrlen - sizeof addr->sa_family : 0;