From: Eric Botcazou Date: Fri, 24 Oct 2025 13:38:00 +0000 (+0200) Subject: Ada: Fix strange control flow in terminals.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e56b72872d6daa775dd4a486c15cd85fe910c4e1;p=thirdparty%2Fgcc.git Ada: Fix strange control flow in terminals.c This was caught by a static analyzer some time ago. gcc/ada/ PR ada/98879 * terminals.c (__gnat_setup_child_communication) [_WIN32]: Add else blocks in the processing of the data returned by ReadFile. --- diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c index 89f887556c0..85a5c0dcbd9 100644 --- a/gcc/ada/terminals.c +++ b/gcc/ada/terminals.c @@ -724,13 +724,16 @@ __gnat_setup_child_communication if (bRet == FALSE) { cpid = -1; } - - dwRet = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); - if (dwRet != 0) { - cpid = -1; + else { + dwRet = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); + if (dwRet != 0) { + cpid = -1; + } + else { + cpid = buf[4] | (buf[5] << 8) | (buf[6] << 16) | (buf[7] << 24); + } } - cpid = buf[4] | (buf[5] << 8) | (buf[6] << 16) | (buf[7] << 24); process->pid = cpid; }