From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by sourceware.org (Postfix) with ESMTPS id 1578C3858D3C for ; Mon, 16 May 2022 19:01:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1578C3858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f41.google.com with SMTP id a14-20020a7bc1ce000000b00393fb52a386so133814wmj.1 for ; Mon, 16 May 2022 12:01:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=GS/hJNGMhlPWeJL++DBB8m1DJbYqNhhhmBhiXcrNf4Q=; b=OZNCc6BzITeYIeKTiqss9NsoVW6xRVNtlBXDORLnz0NkYeWFbmjrIFroD48MAwD1VA /1o9Qo8g5tgwU2Y4GT2UYasZ+EHmyNSCAqc+k2AAwrRQQeOOWr4kqk2IFq+uU9Q/elPk LNtFRzozYodz9JVj23FxXlkgF4jTDUU5+YKImyudgDpMnbSv2GgAyc16DxXJiOKBo/7w keidAa4UP9CaBE7Sk7IJE3RUsSlUD/ORxr1XFKMbeZ5ERQsMnV6iyxZDPff6CzprLaai EfE8lu1fV6YgomtFXi2KL3Od1VFaZOi/UUDejD6UUeymzvV6ajno8GgtZ+PCTnwLdwYB D54g== X-Gm-Message-State: AOAM533+Q04DKuG5W77JFebrGr5OintDEq5UoT0oKoDW0KBeQLOCBFCB yEcLXki0yXde/GpMWG6NvgfqZIHQuAc= X-Google-Smtp-Source: ABdhPJwyv5ZkwizMuH1GGe/e3FMvdNAZku7SBJw0L1rurVo7LZfrWgKOJin6WPCaxMZSNHdz1C8zOQ== X-Received: by 2002:a1c:f717:0:b0:396:f89f:897c with SMTP id v23-20020a1cf717000000b00396f89f897cmr10694499wmh.165.1652727691007; Mon, 16 May 2022 12:01:31 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id t11-20020adfba4b000000b0020d0351dbb6sm5788868wrg.80.2022.05.16.12.01.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 May 2022 12:01:29 -0700 (PDT) Message-ID: Date: Mon, 16 May 2022 20:01:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: [ob/pushed] Reindent gdbsupport/event-loop.cc:handle_file_event (Re: [PATCH] gdbsupport/even-loop.cc: simplify !HAVE_POLL paths) Content-Language: en-US To: Tom Tromey Cc: Youling Tang , gdb-patches@sourceware.org References: <20220513074905.21554-1-tangyouling@loongson.cn> <634dfd3e-dca9-3c5a-cf63-2a86ca23e40e@palves.net> <182b2afa-d1ac-510b-b454-f81a98a51598@loongson.cn> <497ca477-d498-9c26-f00c-ca8105ee19ed@palves.net> <98da4669-0d8c-21ec-35c3-76fc6e5bb5cc@loongson.cn> <87pmkdfqlq.fsf@tromey.com> From: Pedro Alves In-Reply-To: <87pmkdfqlq.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2022 19:01:34 -0000 On 2022-05-16 16:24, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves writes: > > Pedro> Like in this following patch. WDYT? > > It seems like a good idea to me. > > Pedro> From 2931c1c66fa0ebcb3fce7dbc7032b9c4243fa4f2 Mon Sep 17 00:00:00 2001 > Pedro> From: Pedro Alves > Pedro> Date: Mon, 16 May 2022 10:11:15 +0100 > Pedro> Subject: [PATCH] gdbsupport/even-loop.cc: simplify !HAVE_POLL paths > > Missing a 't' in the file name in the subject here. Thanks, I fixed that (and the other instance), and applied the obvious follow up patch at the bottom. git diff -w looks like this: ~~~ diff --git c/gdbsupport/event-loop.cc w/gdbsupport/event-loop.cc index 18f57ef8d61..f078c1278a8 100644 --- c/gdbsupport/event-loop.cc +++ w/gdbsupport/event-loop.cc @@ -492,23 +492,21 @@ handle_file_event (file_handler *file_ptr, int ready_mask) { int mask; - { - { - /* With poll, the ready_mask could have any of three events - set to 1: POLLHUP, POLLERR, POLLNVAL. These events - cannot be used in the requested event mask (events), but - they can be returned in the return mask (revents). We - need to check for those event too, and add them to the - mask which will be passed to the handler. */ - - /* See if the desired events (mask) match the received - events (ready_mask). */ + /* See if the desired events (mask) match the received events + (ready_mask). */ #ifdef HAVE_POLL if (use_poll) { int error_mask; + /* With poll, the ready_mask could have any of three events set + to 1: POLLHUP, POLLERR, POLLNVAL. These events cannot be + used in the requested event mask (events), but they can be + returned in the return mask (revents). We need to check for + those event too, and add them to the mask which will be + passed to the handler. */ + /* POLLHUP means EOF, but can be combined with POLLIN to signal more data to read. */ error_mask = POLLHUP | POLLERR | POLLNVAL; @@ -551,8 +549,6 @@ handle_file_event (file_handler *file_ptr, int ready_mask) file_ptr->proc (file_ptr->error, file_ptr->client_data); } } - } -} /* Wait for new events on the monitored file descriptors. Run the event handler if the first descriptor that is detected by the poll. ~~~ Here's what I pushed. >From 187075ebbc0cba7b58685c7214028e791b5af844 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 16 May 2022 12:20:08 +0100 Subject: [PATCH] Reindent gdbsupport/event-loop.cc:handle_file_event The handle_file_event function has a few unnecessary {} lexical blocks, presumably because they were originally if blocks, and the conditions were removed, or something along those lines. Remove the unnecessary blocks, and reindent. Change-Id: Iaecbe5c9f4940a80b81dbbc42e51ce506f6aafb2 --- gdbsupport/event-loop.cc | 104 +++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 54 deletions(-) diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc index 18f57ef8d61..f078c1278a8 100644 --- a/gdbsupport/event-loop.cc +++ b/gdbsupport/event-loop.cc @@ -492,65 +492,61 @@ handle_file_event (file_handler *file_ptr, int ready_mask) { int mask; + /* See if the desired events (mask) match the received events + (ready_mask). */ + +#ifdef HAVE_POLL + if (use_poll) { - { - /* With poll, the ready_mask could have any of three events - set to 1: POLLHUP, POLLERR, POLLNVAL. These events - cannot be used in the requested event mask (events), but - they can be returned in the return mask (revents). We - need to check for those event too, and add them to the - mask which will be passed to the handler. */ + int error_mask; - /* See if the desired events (mask) match the received - events (ready_mask). */ + /* With poll, the ready_mask could have any of three events set + to 1: POLLHUP, POLLERR, POLLNVAL. These events cannot be + used in the requested event mask (events), but they can be + returned in the return mask (revents). We need to check for + those event too, and add them to the mask which will be + passed to the handler. */ -#ifdef HAVE_POLL - if (use_poll) - { - int error_mask; - - /* POLLHUP means EOF, but can be combined with POLLIN to - signal more data to read. */ - error_mask = POLLHUP | POLLERR | POLLNVAL; - mask = ready_mask & (file_ptr->mask | error_mask); - - if ((mask & (POLLERR | POLLNVAL)) != 0) - { - /* Work in progress. We may need to tell somebody - what kind of error we had. */ - if (mask & POLLERR) - warning (_("Error detected on fd %d"), file_ptr->fd); - if (mask & POLLNVAL) - warning (_("Invalid or non-`poll'able fd %d"), - file_ptr->fd); - file_ptr->error = 1; - } - else - file_ptr->error = 0; - } - else -#endif /* HAVE_POLL */ - { - if (ready_mask & GDB_EXCEPTION) - { - warning (_("Exception condition detected on fd %d"), - file_ptr->fd); - file_ptr->error = 1; - } - else - file_ptr->error = 0; - mask = ready_mask & file_ptr->mask; - } + /* POLLHUP means EOF, but can be combined with POLLIN to + signal more data to read. */ + error_mask = POLLHUP | POLLERR | POLLNVAL; + mask = ready_mask & (file_ptr->mask | error_mask); - /* If there was a match, then call the handler. */ - if (mask != 0) - { - event_loop_ui_debug_printf (file_ptr->is_ui, - "invoking fd file handler `%s`", - file_ptr->name.c_str ()); - file_ptr->proc (file_ptr->error, file_ptr->client_data); - } + if ((mask & (POLLERR | POLLNVAL)) != 0) + { + /* Work in progress. We may need to tell somebody + what kind of error we had. */ + if (mask & POLLERR) + warning (_("Error detected on fd %d"), file_ptr->fd); + if (mask & POLLNVAL) + warning (_("Invalid or non-`poll'able fd %d"), + file_ptr->fd); + file_ptr->error = 1; + } + else + file_ptr->error = 0; + } + else +#endif /* HAVE_POLL */ + { + if (ready_mask & GDB_EXCEPTION) + { + warning (_("Exception condition detected on fd %d"), + file_ptr->fd); + file_ptr->error = 1; } + else + file_ptr->error = 0; + mask = ready_mask & file_ptr->mask; + } + + /* If there was a match, then call the handler. */ + if (mask != 0) + { + event_loop_ui_debug_printf (file_ptr->is_ui, + "invoking fd file handler `%s`", + file_ptr->name.c_str ()); + file_ptr->proc (file_ptr->error, file_ptr->client_data); } } base-commit: 36a5b3705352f228cdd14a7f9d5e85177fad034c -- 2.36.0