connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Matthias Gerstner <matthias.gerstner@suse.de>
To: connman@lists.linux.dev
Subject: [PATCH 16/16] dnsproxy: fix compiler warnings (differing signedness, empty format string)
Date: Tue, 18 Oct 2022 10:47:46 +0200	[thread overview]
Message-ID: <20221018084746.21959-17-matthias.gerstner@suse.de> (raw)
In-Reply-To: <20221018084746.21959-1-matthias.gerstner@suse.de>

There are some invocations of functions with implicit casts from
signed/unsigned char or vice versa. This has been inconsisent in the
beginning and future refactoring should choose a harmonized data type
for message buffers, maybe something like `uint8_t*`.
---
 src/dnsproxy.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index 9ab4a6742..5d6e69cf6 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -1362,10 +1362,10 @@ static void cache_refresh(void)
 	g_hash_table_foreach(cache, cache_refresh_iterator, NULL);
 }
 
-static int reply_query_type(const unsigned char *msg, int len)
+static int reply_query_type(const char *msg, size_t len)
 {
 	/* skip the header */
-	const unsigned char *c = msg + DNS_HEADER_SIZE;
+	const unsigned char *c = (const unsigned char*)msg + DNS_HEADER_SIZE;
 	len -= DNS_HEADER_SIZE;
 
 	if (len < 0)
@@ -1416,7 +1416,8 @@ static int cache_update(struct server_data *srv, const char *msg, size_t msg_len
 	question[sizeof(question) - 1] = '\0';
 	int ttl = 0;
 	uint16_t answers = 0, type = 0, class = 0;
-	const int err = parse_response(msg + offset, msg_len - offset,
+	const int err = parse_response(
+				(unsigned char*)(msg + offset), msg_len - offset,
 				question, sizeof(question) - 1,
 				&type, &class, &ttl,
 				response, &rsplen, &answers);
@@ -2293,7 +2294,7 @@ static void destroy_server(struct server_data *server)
 static gboolean udp_server_event(GIOChannel *channel, GIOCondition condition,
 							gpointer user_data)
 {
-	unsigned char buf[4096];
+	char buf[4096];
 	struct server_data *data = user_data;
 
 	if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
@@ -2508,14 +2509,14 @@ hangup:
 		}
 
 		struct request_data *req = lookup_request(
-				reply->buf, reply->received, IPPROTO_TCP);
+				(const char*)reply->buf, reply->received, IPPROTO_TCP);
 
 		if (!req)
 			/* invalid / corrupt request */
 			return TRUE;
 
 		const int res = forward_dns_reply(
-			reply->buf, reply->received, IPPROTO_TCP, server, req);
+			(char*)reply->buf, reply->received, IPPROTO_TCP, server, req);
 
 		g_free(reply);
 		server->incoming_reply = NULL;
@@ -2542,7 +2543,7 @@ static gboolean tcp_idle_timeout(gpointer user_data)
 {
 	struct server_data *server = user_data;
 
-	debug("");
+	debug("\n");
 
 	if (!server)
 		return FALSE;
-- 
2.37.3


  parent reply	other threads:[~2022-10-18  8:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18  8:47 dnsproxy: first round of refactoring, TCP bugfix Matthias Gerstner
2022-10-18  8:47 ` [PATCH 01/16] dnsproxy-simple-test: improve test coverage and test flexibility Matthias Gerstner
2022-10-18  8:47 ` [PATCH 02/16] autoconf: require C99 compiler and set C99 mode Matthias Gerstner
2022-10-18  8:47 ` [PATCH 03/16] dnsproxy: first bits of refactoring data types, global variables, simpler functions Matthias Gerstner
2022-10-24  6:59   ` Daniel Wagner
2022-10-18  8:47 ` [PATCH 04/16] dnsproxy: refactoring of update_cached_ttl() and append_data() Matthias Gerstner
2022-10-18  8:47 ` [PATCH 05/16] dnsproxy: refactor parse_response() Matthias Gerstner
2022-10-18  8:47 ` [PATCH 06/16] dnsproxy: refactoring of cache_update() Matthias Gerstner
2022-10-24  7:03   ` Daniel Wagner
2022-10-18  8:47 ` [PATCH 07/16] dnsproxy: strip_domains(): fix out of bounds read access Matthias Gerstner
2022-10-18  8:47 ` [PATCH 08/16] dnsproxy: refactor and document strip_domains() to make it less confusing Matthias Gerstner
2022-10-18  8:47 ` [PATCH 09/16] dnsproxy: refactor ns_resolv() and forwards_dns_reply() Matthias Gerstner
2022-10-18  8:47 ` [PATCH 10/16] dnsproxy: uncompress: replace unnecessary goto with return statements Matthias Gerstner
2022-10-18  8:47 ` [PATCH 11/16] dnsproxy: forward_dns_reply: pull out separate dns_reply_fixup_domains() Matthias Gerstner
2022-10-18  8:47 ` [PATCH 12/16] dnsproxy: finish first pass of refactoring the compilation unit Matthias Gerstner
2022-10-18  8:47 ` [PATCH 13/16] dnsproxy: fix TCP server reply handling if domain name is appended Matthias Gerstner
2022-10-18  8:47 ` [PATCH 14/16] dnsproxy: harmonize use of sizeof() for message size calculations Matthias Gerstner
2022-10-18  8:47 ` [PATCH 15/16] dnsproxy: add my copyright statement covering the larger refactoring changes Matthias Gerstner
2022-10-18  8:47 ` Matthias Gerstner [this message]
2022-10-18  8:55 ` dnsproxy: first round of refactoring, TCP bugfix Matthias Gerstner
2022-10-24  7:40   ` Daniel Wagner
  -- strict thread matches above, loose matches on Subject: below --
2022-06-10 12:33 Matthias Gerstner
2022-06-10 12:33 ` [PATCH 16/16] dnsproxy: fix compiler warnings (differing signedness, empty format string) Matthias Gerstner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221018084746.21959-17-matthias.gerstner@suse.de \
    --to=matthias.gerstner@suse.de \
    --cc=connman@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).