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 1DD431F4B4 for ; Tue, 2 Feb 2021 10:02:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231195AbhBBJ7L (ORCPT ); Tue, 2 Feb 2021 04:59:11 -0500 Received: from cloud.peff.net ([104.130.231.41]:44282 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230083AbhBBJ7B (ORCPT ); Tue, 2 Feb 2021 04:59:01 -0500 Received: (qmail 12784 invoked by uid 109); 2 Feb 2021 09:58:20 -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:58:20 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 703 invoked by uid 111); 2 Feb 2021 09:58:20 -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:58:20 -0500 Authentication-Results: peff.net; auth=none Date: Tue, 2 Feb 2021 04:58:19 -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: > static int chdir_len(const char *orig, int len) > { > char *path = xmemdupz(orig, len); > @@ -79,7 +71,10 @@ int unix_stream_connect(const char *path) > > if (unix_sockaddr_init(&sa, path, &ctx) < 0) > return -1; > - fd = unix_stream_socket(); > + fd = socket(AF_UNIX, SOCK_STREAM, 0); > + if (fd < 0) > + die_errno("unable to create socket"); > + Reading the next patch, I suddenly realized that these are die calls, and not just passing along the error (which you then fix in the next patch). It seems like that should be happening here in this patch. Callers must already be ready to handle an error (we return -1 in the context above). > @@ -103,7 +98,9 @@ int unix_stream_listen(const char *path) > > if (unix_sockaddr_init(&sa, path, &ctx) < 0) > return -1; > - fd = unix_stream_socket(); > + fd = socket(AF_UNIX, SOCK_STREAM, 0); > + if (fd < 0) > + die_errno("unable to create socket"); Ditto here. -Peff