diff mbox

[1/3] gtp.c: improve an error log.

Message ID 1444611275-2552-2-git-send-email-nhofmeyr@sysmocom.de
State Superseded
Headers show

Commit Message

Neels Hofmeyr Oct. 12, 2015, 12:54 a.m. UTC
It would print the memory location of the address buffer. Instead, print the
first few hex values of the address buffer.
---
 gtp/gtp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Holger Freyther Oct. 12, 2015, 7:22 a.m. UTC | #1
> On 12 Oct 2015, at 02:54, Neels Hofmeyr <nhofmeyr@sysmocom.de> wrote:
> 
> diff --git a/gtp/gtp.c b/gtp/gtp.c
> index cfce244..90e0326 100644
> --- a/gtp/gtp.c
> +++ b/gtp/gtp.c
> @@ -741,7 +741,7 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen,
> 		(*gsn)->err_socket++;
> 		LOGP(DLGTP, LOGL_ERROR,
> 			"bind(fd0=%d, addr=%lx, len=%d) failed: Error = %s\n",
> -			(*gsn)->fd0, (unsigned long)&addr, sizeof(addr),
> +			(*gsn)->fd0, *((unsigned long*)&addr), sizeof(addr),

did you run into this?  At first I wanted to say then use osmo_hexdump but
as this is an in_addr.. a user wants to see the IP addr and the port number
that could not be bound to. Could you improve this?

holger
Neels Hofmeyr Oct. 12, 2015, 8:46 a.m. UTC | #2
On Mon, Oct 12, 2015 at 09:22:53AM +0200, Holger Freyther wrote:
> 
> > On 12 Oct 2015, at 02:54, Neels Hofmeyr <nhofmeyr@sysmocom.de> wrote:
> > 
> > diff --git a/gtp/gtp.c b/gtp/gtp.c
> > index cfce244..90e0326 100644
> > --- a/gtp/gtp.c
> > +++ b/gtp/gtp.c
> > @@ -741,7 +741,7 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen,
> > 		(*gsn)->err_socket++;
> > 		LOGP(DLGTP, LOGL_ERROR,
> > 			"bind(fd0=%d, addr=%lx, len=%d) failed: Error = %s\n",
> > -			(*gsn)->fd0, (unsigned long)&addr, sizeof(addr),
> > +			(*gsn)->fd0, *((unsigned long*)&addr), sizeof(addr),
> 
> did you run into this?

yea, during testing, when the port was already bound or the address was
invalid. I was puzzled by the hex value and figured that this would have
been the intended thing to print. But it's not great at all.

> a user wants to see the IP addr and the port number that could not be
> bound to. Could you improve this?

probably, yes... I'll come back to this later.

~Neels
diff mbox

Patch

diff --git a/gtp/gtp.c b/gtp/gtp.c
index cfce244..90e0326 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -741,7 +741,7 @@  int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen,
 		(*gsn)->err_socket++;
 		LOGP(DLGTP, LOGL_ERROR,
 			"bind(fd0=%d, addr=%lx, len=%d) failed: Error = %s\n",
-			(*gsn)->fd0, (unsigned long)&addr, sizeof(addr),
+			(*gsn)->fd0, *((unsigned long*)&addr), sizeof(addr),
 			strerror(errno));
 		return -1;
 	}