v5: add missing function prototypes to address build errors.
This commit adds missing function prototypes to resolve build errors
triggered by the -Werror=missing-prototypes compiler flag.
Bug: 293694479
Test: TH
Change-Id: I3d22c9e7892585a2829db192d489af4dbe4809ce
diff --git a/apf_checksum.h b/apf_checksum.h
index 2c5468e..aa143a0 100644
--- a/apf_checksum.h
+++ b/apf_checksum.h
@@ -2,7 +2,7 @@
* Calculate big endian 16-bit sum of a buffer (max 128kB),
* then fold and negate it, producing a 16-bit result in [0..FFFE].
*/
-u16 calc_csum(u32 sum, const u8* const buf, const s32 len) {
+FUNC(u16 calc_csum(u32 sum, const u8* const buf, const s32 len)) {
s32 i;
for (i = 0; i < len; ++i) sum += buf[i] * ((i & 1) ? 1 : 256);
@@ -44,8 +44,8 @@
*
* @return 6-bit DSCP value [0..63], garbage on parse error.
*/
-int csum_and_return_dscp(u8* const pkt, const s32 len, const u8 ip_ofs,
- const u16 partial_csum, const u8 csum_start, const u8 csum_ofs, const bool udp) {
+FUNC(int csum_and_return_dscp(u8* const pkt, const s32 len, const u8 ip_ofs,
+ const u16 partial_csum, const u8 csum_start, const u8 csum_ofs, const bool udp)) {
if (csum_ofs < 255) {
// note that calc_csum() treats negative lengths as zero
u32 csum = calc_csum(partial_csum, pkt + csum_start, len - csum_start);
diff --git a/apf_defs.h b/apf_defs.h
index e46802c..af63025 100644
--- a/apf_defs.h
+++ b/apf_defs.h
@@ -37,3 +37,5 @@
#define IPV6_HLEN 40
#define TCP_HLEN 20
#define UDP_HLEN 8
+
+#define FUNC(x) x; x
diff --git a/apf_dns.h b/apf_dns.h
index 60ab132..0d25893 100644
--- a/apf_dns.h
+++ b/apf_dns.h
@@ -12,11 +12,11 @@
*
* @return 1 if matched, 0 if not matched, -1 if error in packet, -2 if error in program.
*/
-match_result_type match_single_name(const u8* needle,
+FUNC(match_result_type match_single_name(const u8* needle,
const u8* const needle_bound,
const u8* const udp,
const u32 udp_len,
- u32* const ofs) {
+ u32* const ofs)) {
u32 first_unread_offset = *ofs;
bool is_qname_match = true;
int lvl;
@@ -75,11 +75,11 @@
*
* @return 1 if matched, 0 if not matched, -1 if error in packet, -2 if error in program.
*/
-match_result_type match_names(const u8* needles,
+FUNC(match_result_type match_names(const u8* needles,
const u8* const needle_bound,
const u8* const udp,
const u32 udp_len,
- const int question_type) {
+ const int question_type)) {
if (udp_len < 12) return error_packet; /* lack of dns header */
/* dns header: be16 tid, flags, num_{questions,answers,authority,additional} */
diff --git a/v5/Android.bp b/v5/Android.bp
index 8a4084a..19faf78 100644
--- a/v5/Android.bp
+++ b/v5/Android.bp
@@ -25,6 +25,7 @@
"-Wall",
"-Werror",
"-Werror=implicit-fallthrough",
+ "-Werror=missing-prototypes",
"-Werror=strict-prototypes",
"-Wnullable-to-nonnull-conversion",
"-Wsign-compare",
diff --git a/v5/apf_interpreter.c b/v5/apf_interpreter.c
index b8ce799..d86647a 100644
--- a/v5/apf_interpreter.c
+++ b/v5/apf_interpreter.c
@@ -72,6 +72,8 @@
#define IPV6_HLEN 40
#define TCP_HLEN 20
#define UDP_HLEN 8
+
+#define FUNC(x) x; x
/* End include of apf_defs.h */
/* Begin include of apf.h */
/*
@@ -393,11 +395,11 @@
*
* @return 1 if matched, 0 if not matched, -1 if error in packet, -2 if error in program.
*/
-match_result_type match_single_name(const u8* needle,
+FUNC(match_result_type match_single_name(const u8* needle,
const u8* const needle_bound,
const u8* const udp,
const u32 udp_len,
- u32* const ofs) {
+ u32* const ofs)) {
u32 first_unread_offset = *ofs;
bool is_qname_match = true;
int lvl;
@@ -456,11 +458,11 @@
*
* @return 1 if matched, 0 if not matched, -1 if error in packet, -2 if error in program.
*/
-match_result_type match_names(const u8* needles,
+FUNC(match_result_type match_names(const u8* needles,
const u8* const needle_bound,
const u8* const udp,
const u32 udp_len,
- const int question_type) {
+ const int question_type)) {
if (udp_len < 12) return error_packet; /* lack of dns header */
/* dns header: be16 tid, flags, num_{questions,answers,authority,additional} */
@@ -510,7 +512,7 @@
* Calculate big endian 16-bit sum of a buffer (max 128kB),
* then fold and negate it, producing a 16-bit result in [0..FFFE].
*/
-u16 calc_csum(u32 sum, const u8* const buf, const s32 len) {
+FUNC(u16 calc_csum(u32 sum, const u8* const buf, const s32 len)) {
s32 i;
for (i = 0; i < len; ++i) sum += buf[i] * ((i & 1) ? 1 : 256);
@@ -552,8 +554,8 @@
*
* @return 6-bit DSCP value [0..63], garbage on parse error.
*/
-int csum_and_return_dscp(u8* const pkt, const s32 len, const u8 ip_ofs,
- const u16 partial_csum, const u8 csum_start, const u8 csum_ofs, const bool udp) {
+FUNC(int csum_and_return_dscp(u8* const pkt, const s32 len, const u8 ip_ofs,
+ const u16 partial_csum, const u8 csum_start, const u8 csum_ofs, const bool udp)) {
if (csum_ofs < 255) {
/* note that calc_csum() treats negative lengths as zero */
u32 csum = calc_csum(partial_csum, pkt + csum_start, len - csum_start);
@@ -596,7 +598,7 @@
#define ENFORCE_UNSIGNED(c) ((c)==(u32)(c))
u32 apf_version(void) {
- return 20240214;
+ return 20240226;
}
typedef struct {
@@ -615,7 +617,7 @@
memory_type mem; /* Memory slot values. */
} apf_context;
-int do_transmit_buffer(apf_context* ctx, u32 pkt_len, u8 dscp) {
+FUNC(int do_transmit_buffer(apf_context* ctx, u32 pkt_len, u8 dscp)) {
int ret = apf_transmit_buffer(ctx->caller_ctx, ctx->tx_buf, pkt_len, dscp);
ctx->tx_buf = NULL;
ctx->tx_buf_len = 0;
diff --git a/v5/apf_interpreter_source.c b/v5/apf_interpreter_source.c
index 66b0559..24dbbca 100644
--- a/v5/apf_interpreter_source.c
+++ b/v5/apf_interpreter_source.c
@@ -61,7 +61,7 @@
#define ENFORCE_UNSIGNED(c) ((c)==(u32)(c))
u32 apf_version(void) {
- return 20240214;
+ return 20240226;
}
typedef struct {
@@ -80,7 +80,7 @@
memory_type mem; // Memory slot values.
} apf_context;
-int do_transmit_buffer(apf_context* ctx, u32 pkt_len, u8 dscp) {
+FUNC(int do_transmit_buffer(apf_context* ctx, u32 pkt_len, u8 dscp)) {
int ret = apf_transmit_buffer(ctx->caller_ctx, ctx->tx_buf, pkt_len, dscp);
ctx->tx_buf = NULL;
ctx->tx_buf_len = 0;