From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91003C433E0 for ; Tue, 2 Feb 2021 09:55:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 487C464F54 for ; Tue, 2 Feb 2021 09:55:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231243AbhBBJz3 (ORCPT ); Tue, 2 Feb 2021 04:55:29 -0500 Received: from cloud.peff.net ([104.130.231.41]:44264 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbhBBJzF (ORCPT ); Tue, 2 Feb 2021 04:55:05 -0500 Received: (qmail 12741 invoked by uid 109); 2 Feb 2021 09:54:22 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Tue, 02 Feb 2021 09:54:22 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 638 invoked by uid 111); 2 Feb 2021 09:54:22 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Tue, 02 Feb 2021 04:54:22 -0500 Authentication-Results: peff.net; auth=none Date: Tue, 2 Feb 2021 04:54:21 -0500 From: Jeff King To: Jeff Hostetler via GitGitGadget Cc: git@vger.kernel.org, =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jeff Hostetler , Chris Torek , Jeff Hostetler Subject: Re: [PATCH v2 10/14] unix-socket: elimiate static unix_stream_socket() helper function Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Feb 01, 2021 at 07:45:43PM +0000, Jeff Hostetler via GitGitGadget wrote: > From: Jeff Hostetler > > The static helper function `unix_stream_socket()` calls `die()`. This is not > appropriate for all callers. Eliminate the wrapper function and move the > existing error handling to the callers in preparation for adapting specific > callers. Thanks, this looks good. > -static int unix_stream_socket(void) > -{ > - int fd = socket(AF_UNIX, SOCK_STREAM, 0); > - if (fd < 0) > - die_errno("unable to create socket"); > - return fd; > -} This could become a one-liner: return socket(AF_UNIX, SOCK_STREAM, 0); to keep the details abstracted. But it's local to this file, the callers are already necessarily full of bsd-socket arcana, and it's not like the magic words there have ever changed in 30+ years. Putting it inline seems quite reasonable. :) -Peff