mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
"default:" case handling: improved portability, streamlined
This commit is contained in:
@@ -72,6 +72,7 @@ mhd_conn_process_recv_send_data (struct MHD_Connection *restrict c)
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* MHD_ENABLE_HTTPS */
|
||||
|
||||
@@ -399,6 +399,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
default:
|
||||
sk_type = mhd_SKT_UNKNOWN;
|
||||
p_use_sa = NULL; /* To be set below */
|
||||
break;
|
||||
}
|
||||
|
||||
if (s->bind_sa.v_dual)
|
||||
@@ -594,7 +595,6 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
case mhd_SKT_UNIX:
|
||||
case mhd_SKT_NO_SOCKET:
|
||||
default:
|
||||
mhd_assert (0);
|
||||
mhd_UNREACHABLE ();
|
||||
return MHD_SC_INTERNAL_ERROR;
|
||||
}
|
||||
@@ -971,7 +971,6 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
break;
|
||||
case mhd_SKT_NO_SOCKET:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
return MHD_SC_INTERNAL_ERROR;
|
||||
}
|
||||
@@ -1339,10 +1338,8 @@ daemon_choose_and_preinit_events (struct MHD_Daemon *restrict d,
|
||||
#endif /* ! MHD_USE_EPOLL */
|
||||
case mhd_POLL_TYPE_NOT_SET_YET:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
return MHD_SC_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
return MHD_SC_OK;
|
||||
}
|
||||
@@ -1753,7 +1750,8 @@ allocate_events (struct MHD_Daemon *restrict d)
|
||||
#endif /* ! MHD_USE_EPOLL */
|
||||
case mhd_POLL_TYPE_NOT_SET_YET:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
mhd_UNREACHABLE ();
|
||||
return MHD_SC_INTERNAL_ERROR;
|
||||
@@ -1988,7 +1986,8 @@ add_itc_and_listen_to_monitoring (struct MHD_Daemon *restrict d)
|
||||
#endif /* ! MHD_USE_EPOLL */
|
||||
case mhd_POLL_TYPE_NOT_SET_YET:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
mhd_UNREACHABLE ();
|
||||
return MHD_SC_INTERNAL_ERROR;
|
||||
@@ -2366,7 +2365,7 @@ set_d_threading_type (struct MHD_Daemon *restrict d)
|
||||
case mhd_WM_INT_INTERNAL_EVENTS_THREAD_POOL:
|
||||
#endif /* ! MHD_USE_THREADS */
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
break;
|
||||
}
|
||||
mhd_UNREACHABLE ();
|
||||
return MHD_SC_INTERNAL_ERROR;
|
||||
|
||||
@@ -1099,9 +1099,9 @@ process_all_events_and_data (struct MHD_Daemon *restrict d)
|
||||
#endif /* ! MHD_USE_EPOLL */
|
||||
case mhd_POLL_TYPE_NOT_SET_YET:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
MHD_PANIC ("Daemon data integrity broken");
|
||||
break;
|
||||
}
|
||||
if (d->events.act_req.accept)
|
||||
{
|
||||
|
||||
@@ -705,7 +705,6 @@ mhd_monotonic_msec_counter (void)
|
||||
#endif /* _WIN32_WINNT < 0x0600 */
|
||||
#endif /* _WIN32 */
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -401,8 +401,8 @@ init_post_parse_data (struct MHD_Connection *restrict c)
|
||||
break;
|
||||
case MHD_HTTP_POST_ENCODING_OTHER:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1326,7 +1326,6 @@ parse_post_urlenc (struct MHD_Connection *restrict c,
|
||||
reset_parse_field_data_urlenc (p_data);
|
||||
continue; /* Process the next char */
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
@@ -2069,7 +2068,6 @@ parse_post_mpart (struct MHD_Connection *restrict c,
|
||||
c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED;
|
||||
return true;
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
@@ -2291,7 +2289,6 @@ parse_post_text (struct MHD_Connection *restrict c,
|
||||
reset_parse_field_data_text (p_data);
|
||||
continue; /* Process the next char */
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
enc_broken = true;
|
||||
break;
|
||||
@@ -2425,7 +2422,6 @@ mhd_stream_post_parse (struct MHD_Connection *restrict c,
|
||||
break;
|
||||
case MHD_HTTP_POST_ENCODING_OTHER:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
p_data->parse_result =
|
||||
MHD_POST_PARSE_RES_PARTIAL_INVALID_POST_FORMAT;
|
||||
@@ -2570,7 +2566,6 @@ check_post_leftovers_urlenc (struct MHD_Connection *restrict c,
|
||||
case mhd_POST_UENC_ST_AT_EQ:
|
||||
case mhd_POST_UENC_ST_AT_AMPRSND:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
p_data->parse_result = MHD_POST_PARSE_RES_FAILED_INVALID_POST_FORMAT;
|
||||
return false;
|
||||
@@ -2707,7 +2702,6 @@ check_post_leftovers_mpart (struct MHD_Connection *restrict c,
|
||||
case mhd_POST_MPART_ST_VALUE_END_FOUND:
|
||||
case mhd_POST_MPART_ST_VALUE_END_FOUND_FINAL:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
p_data->parse_result = MHD_POST_PARSE_RES_FAILED_INVALID_POST_FORMAT;
|
||||
return false;
|
||||
@@ -2839,7 +2833,6 @@ check_post_leftovers_text (struct MHD_Connection *restrict c,
|
||||
case mhd_POST_TEXT_ST_AT_LF_BARE:
|
||||
case mhd_POST_TEXT_ST_AT_CR:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
p_data->parse_result = MHD_POST_PARSE_RES_FAILED_INVALID_POST_FORMAT;
|
||||
return false;
|
||||
@@ -2907,7 +2900,6 @@ check_post_leftovers (struct MHD_Connection *restrict c)
|
||||
c->rq.cntn.lbuf.data);
|
||||
case MHD_HTTP_POST_ENCODING_OTHER:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
p_data->parse_result =
|
||||
MHD_POST_PARSE_RES_PARTIAL_INVALID_POST_FORMAT;
|
||||
|
||||
@@ -82,6 +82,7 @@ MHD_request_get_info_fixed_sz (
|
||||
return MHD_SC_OK;
|
||||
case MHD_REQUEST_INFO_FIXED_SENTINEL:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return MHD_SC_INFO_GET_TYPE_UNKNOWN;
|
||||
@@ -159,6 +160,7 @@ MHD_request_get_info_dynamic_sz (
|
||||
break;
|
||||
case MHD_REQUEST_INFO_DYNAMIC_SENTINEL:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return MHD_SC_INFO_GET_TYPE_UNKNOWN;
|
||||
|
||||
@@ -779,8 +779,8 @@ mhd_conn_start_closing (struct MHD_Connection *restrict c,
|
||||
case mhd_SOCKET_ERR_AGAIN:
|
||||
case mhd_SOCKET_ERR_INTR:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case mhd_CONN_CLOSE_DAEMON_SHUTDOWN:
|
||||
@@ -821,6 +821,7 @@ mhd_conn_start_closing (struct MHD_Connection *restrict c,
|
||||
mhd_UNREACHABLE ();
|
||||
end_code = MHD_REQUEST_ENDED_COMPLETED_OK;
|
||||
close_hard = false;
|
||||
break;
|
||||
}
|
||||
|
||||
mhd_assert ((NULL == log_msg) || (MHD_SC_INTERNAL_ERROR != sc));
|
||||
|
||||
@@ -325,7 +325,6 @@ setup_reply_properties (struct MHD_Connection *restrict c)
|
||||
break;
|
||||
case mhd_RESPONSE_CONTENT_DATA_INVALID:
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
c->rp.cntn_loc = mhd_REPLY_CNTN_LOC_NOWHERE;
|
||||
break;
|
||||
@@ -959,7 +958,6 @@ preprocess_dcc_action (struct MHD_Connection *restrict c,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
mhd_STREAM_ABORT (c,
|
||||
mhd_CONN_CLOSE_INT_ERROR,
|
||||
@@ -1018,7 +1016,6 @@ read_response_file (struct MHD_Connection *restrict c,
|
||||
"than specified by application.");
|
||||
return false;
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
c->rp.cntn_loc = mhd_REPLY_CNTN_LOC_NOWHERE;
|
||||
return false;
|
||||
|
||||
@@ -2535,7 +2535,6 @@ parse_cookie_header (struct MHD_Connection *restrict connection,
|
||||
"parse client cookies!\n");
|
||||
break;
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
@@ -3727,7 +3726,7 @@ handle_recv_no_space (struct MHD_Connection *c,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mhd_assert (0 && "Should be unreachable");
|
||||
mhd_UNREACHABLE ();
|
||||
}
|
||||
|
||||
|
||||
@@ -3942,9 +3941,9 @@ mhd_stream_check_and_grow_read_buffer_space (struct MHD_Connection *restrict c)
|
||||
case mhd_HTTP_STAGE_UPGRADED_CLEANING:
|
||||
#endif /* MHD_UPGRADE_SUPPORT */
|
||||
default:
|
||||
mhd_assert (0);
|
||||
mhd_UNREACHABLE ();
|
||||
stage = MHD_PROC_RECV_BODY_NORMAL;
|
||||
break;
|
||||
}
|
||||
|
||||
handle_recv_no_space (c, stage);
|
||||
|
||||
@@ -173,8 +173,8 @@ mhd_conn_event_loop_state_update (struct MHD_Connection *restrict c)
|
||||
c->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP;
|
||||
break;
|
||||
default:
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ mhd_tls_multi_is_edge_trigg_supported (struct DaemonOptions *s)
|
||||
break;
|
||||
default:
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -220,6 +221,7 @@ tls_daemon_init_try (enum mhd_TlsMultiRoute route,
|
||||
#endif
|
||||
case mhd_TLS_MULTI_ROUTE_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mhd_assert (0 && "Impossible value");
|
||||
mhd_UNREACHABLE ();
|
||||
@@ -300,10 +302,9 @@ mhd_tls_multi_daemon_init (struct MHD_Daemon *restrict d,
|
||||
#endif /* ! MHD_USE_OPENSSL */
|
||||
case MHD_TLS_BACKEND_NONE:
|
||||
default:
|
||||
break;
|
||||
mhd_assert (0 && "Should not be reachable");
|
||||
mhd_UNREACHABLE ();
|
||||
res = MHD_SC_TLS_BACKEND_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
mhd_assert (NULL != d_tls);
|
||||
if (MHD_SC_OK == res)
|
||||
@@ -341,6 +342,7 @@ mhd_tls_multi_daemon_deinit (struct mhd_TlsMultiDaemonData *restrict d_tls)
|
||||
case mhd_TLS_MULTI_ROUTE_NONE:
|
||||
default:
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
free (d_tls);
|
||||
}
|
||||
@@ -415,6 +417,7 @@ mhd_tls_multi_conn_init (const struct mhd_TlsMultiDaemonData *restrict d_tls,
|
||||
case mhd_TLS_MULTI_ROUTE_NONE:
|
||||
default:
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -479,6 +482,7 @@ mhd_tls_multi_conn_handshake (struct mhd_TlsMultiConnData *restrict c_tls)
|
||||
case mhd_TLS_MULTI_ROUTE_NONE:
|
||||
default:
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
return mhd_TLS_PROCED_FAILED;
|
||||
}
|
||||
@@ -507,6 +511,7 @@ mhd_tls_multi_conn_shutdown (struct mhd_TlsMultiConnData *restrict c_tls)
|
||||
case mhd_TLS_MULTI_ROUTE_NONE:
|
||||
default:
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
return mhd_TLS_PROCED_FAILED;
|
||||
}
|
||||
@@ -547,6 +552,7 @@ mhd_tls_multi_conn_recv (struct mhd_TlsMultiConnData *restrict c_tls,
|
||||
case mhd_TLS_MULTI_ROUTE_NONE:
|
||||
default:
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
return mhd_SOCKET_ERR_INTERNAL;
|
||||
}
|
||||
@@ -574,6 +580,7 @@ mhd_tls_multi_conn_has_data_in (struct mhd_TlsMultiConnData *restrict c_tls)
|
||||
case mhd_TLS_MULTI_ROUTE_NONE:
|
||||
default:
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -612,6 +619,7 @@ mhd_tls_multi_conn_send (struct mhd_TlsMultiConnData *restrict c_tls,
|
||||
case mhd_TLS_MULTI_ROUTE_NONE:
|
||||
default:
|
||||
mhd_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
return mhd_SOCKET_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user