Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: bgpd vs gcc14 and session_req_hard_reset return
To:
tech@openbsd.org
Date:
Tue, 17 Dec 2024 14:58:24 +0100

Download raw body.

Thread
On Tue, Dec 17, 2024 at 02:55:40PM +0100, Claudio Jeker wrote:
> Seen this on linux while building protable.
> 
>   CC       bgpd-session.o
> ../../../openbgpd-portable/src/bgpd/session.c: In function
> ‘session_req_hard_reset’:
> ../../../openbgpd-portable/src/bgpd/session.c:1748:1: warning: control
> reaches end of non-void function [-Wreturn-type]
>  1748 | }
>       | ^
> 
> It seems gcc is unable to know that all cases are covered.
> So rewrite this function to have a default return 1 instead.

ok tb

> -- 
> :wq Claudio
> 
> Index: session.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
> diff -u -p -r1.504 session.c
> --- session.c	13 Dec 2024 19:21:03 -0000	1.504
> +++ session.c	17 Dec 2024 13:51:23 -0000
> @@ -1705,6 +1705,7 @@ session_update(uint32_t peerid, struct i
>  	p->stats.msg_sent_update++;
>  }
>  
> +/* Return 1 if a hard reset should be issued, 0 for a graceful notification */
>  static int
>  session_req_hard_reset(enum err_codes errcode, uint8_t subcode)
>  {
> @@ -1719,7 +1720,7 @@ session_req_hard_reset(enum err_codes er
>  		 * is not trustworthy and so there is no realistic
>  		 * hope that forwarding can continue.
>  		 */
> -		return 1;
> +		break;
>  	case ERR_HOLDTIMEREXPIRED:
>  	case ERR_SENDHOLDTIMEREXPIRED:
>  		/* Keep forwarding and hope the other side is back soon. */
> @@ -1733,8 +1734,9 @@ session_req_hard_reset(enum err_codes er
>  			/* Per RFC8538 suggestion make these graceful. */
>  			return 0;
>  		}
> -		return 1;
> +		break;
>  	}
> +	return 1;
>  }
>  
>  void
>