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-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 57DC81F4B4 for ; Tue, 2 Feb 2021 09:58:27 +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