From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 097491F9FF; Wed, 23 Mar 2022 08:54:36 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/3] recv_cmd: do not undef recvmsg buffer arg on errors Date: Wed, 23 Mar 2022 08:54:34 +0000 Message-Id: <20220323085435.1391088-3-e@80x24.org> In-Reply-To: <20220323085435.1391088-1-e@80x24.org> References: <20220323085435.1391088-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It's a waste of ops and cycles, and inconsistent with perl sysread() behavior which doesn't touch the supplied buffer on errors. --- lib/PublicInbox/CmdIPC4.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/CmdIPC4.pm b/lib/PublicInbox/CmdIPC4.pm index c3a7f56e..76938b6d 100644 --- a/lib/PublicInbox/CmdIPC4.pm +++ b/lib/PublicInbox/CmdIPC4.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2020-2021 all contributors +# Copyright (C) all contributors # License: AGPL-3.0+ # callers should use PublicInbox::CmdIPC4->can('send_cmd4') (or recv_cmd4) @@ -32,7 +32,7 @@ no warnings 'once'; *recv_cmd4 = sub ($$$) { my ($s, undef, $len) = @_; # $_[1] = destination buffer my $mh = Socket::MsgHdr->new(buflen => $len, controllen => 256); - my $r = Socket::MsgHdr::recvmsg($s, $mh, 0) // return ($_[1] = undef); + my $r = Socket::MsgHdr::recvmsg($s, $mh, 0) // return (undef); $_[1] = $mh->buf; return () if $r == 0; my (undef, undef, $data) = $mh->cmsghdr;