From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A1965208BC for ; Mon, 21 Sep 2026 22:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790030088; cv=none; b=fjpxizdHDMjJJyQBx0NAIXOm3uPP4dJJ4+3wrx9KG6lL5P+52rmjmjWpuIHmJlHrTj1EqOxAeJnMz63+CF5SLp2la2R0fCBeqZ5ZegxNRjrQPjlJFfUS2SZiZH+v8ja622fxzJTx3wotW/vrf5gy1EZGoqr9noNco5GXgqzZw7A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790030088; c=relaxed/simple; bh=G1tSlQQ7AH66Mdp3ijFGPTQmvH5OU5Axr+xJaSWbHOA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=JHh3WDmK5146jecLmbYnbNYJfqTkMUIzwfKN9TFBPzKvDdphm5yYL004ObufF5AI4PVfQW/XAWQ+vsZhQ44Df8bGKF/Xg8GNiH7G/yrYLtZUgdLXDVSCN5sSJdCfQZpBQwaFxHmNbkM54ucUSBfdFrUNsFqGe7VWi9o2ht3Gl5s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=GX3oRgp4; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=bYFzLYMC; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="GX3oRgp4"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bYFzLYMC" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id AF0E4EC02B6; Mon, 21 Sep 2026 18:34:45 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-02.internal (MEProxy); Mon, 21 Sep 2026 18:34:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1790030085; x=1790116485; bh=k5t8Z5wotM F+3r3rH9UKFmoKXsN/sGW1bDsKFwclikk=; b=GX3oRgp4U7+Hyp+OOxRoj1Z+fS alybiJKHO4dvHmTJsJRRvkbbazEj+IyVzR4e6ReK8LKrikE8EVoyu31irigToMpK ZkrDjywGdIYcBtokJtqvFIXDQYNllmg4a+32Zpz+vpsF37UjHEQF8JHnK3cMeKHb N+bt68jJGvVO6zdwU+V3R7n1pAGf/No3GBn1BtkcEcVjHGHWAEh1s64qoxFcuFbI Vmteb1y0U8E/H7hWodz0BwwNIsGPmHyh5Y+GAHtr+qhnZztUmV1W5JcZHdAOMe9o ukJ9fIDnePTnvSrb9YT6H0vei1cZglp+s4dR2+ntWCjcLqHJHKuER98IaQ9Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1790030085; x=1790116485; bh=k5t8Z5wotMF+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YWTFeCECVJIcaVZf8yPhBP3KGFbtJrgnt2V9CRKQ X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Sep 2026 18:34:45 -0400 (EDT) From: Junio C Hamano To: "Derrick Stolee via GitGitGadget" Cc: git@vger.kernel.org, peff@peff.net, newren@gmail.com, Derrick Stolee Subject: Re: [PATCH 6/6] strbuf-safe: add init and release methods In-Reply-To: (Junio C. Hamano's message of "Mon, 21 Sep 2026 14:44:49 -0700") References: Date: Mon, 21 Sep 2026 15:34:43 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Junio C Hamano writes: > "Derrick Stolee via GitGitGadget" writes: > >> +int jw_release(struct json_writer *jw) >> { >> - strbuf_release(&jw->json); >> - strbuf_release(&jw->open_stack); >> + enum safe_result result = SUCCESS; >> + >> + /* attempt both removals without short-circuiting. */ >> + result = sstrbuf_release(&jw->json) || result; >> + result = sstrbuf_release(&jw->open_stack) || result; >> + >> + return result; >> } > > This is puzzling in a few ways. > If we mean "enum safe_result" is an enumeration of different kinds > of errors, then the "result" variable and the returned value from > ... > On the other hand, if we mean "enum safe_result" is an enumeration > of bitmasks, each bit representing different kind of error, then > ... I forgot the third possibility. Regardless of which interpretation of "enum safe_result" we use, if jw_release() is designed to say "0 for success, non-zero for failure", then almost as written but declaring "result" as a plain "int" int result = 0; result = sstrbuf_release(&jw->json) || result; result = sstrbuf_release(&jw->open_stack) || result; return result; would probably make sense, even though the "|| result" construct is a bit unusual in C. Thanks.