From patchwork Fri Apr 12 23:26:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1084992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="E9WcvtZ5"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44gvHX3nX7z9s6w for ; Sat, 13 Apr 2019 09:29:28 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7CA4F18FA; Fri, 12 Apr 2019 23:26:33 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 90ECE1882 for ; Fri, 12 Apr 2019 23:26:29 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 467D885B for ; Fri, 12 Apr 2019 23:26:29 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id g12so5803436pll.11 for ; Fri, 12 Apr 2019 16:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=82JMUvyYl2pnxY4EIF3/0Ds1qlJ2yc9NiH+iYjuEbcA=; b=E9WcvtZ5JXi2H/AvBOLqUjLZWQM6SChn2zPzaKhcKKQLbhUQlaI3UOcOR+XjtePxfS a4GUv8QvZmogWlqG6lVpUDS0Xu9mU86svGrlKQzVIydodLeWHgeGngov5+/UD+klmOOG 9XEeoaAY+pZnrSp2AusKAisuO+esYMMiiGAhrtep6rL2NBWTJXZttLKOB6aZAsEENEhN mI3kFOREmfZ9Pcq6b8u34JJI8mFerjnnU7RdR18fX1fAsa6049ji8EiGxcKMVYxKbhBk zgy72L/rrYgS4ec/MdhzU2NZ3tFZaMf+rC/l1zvRz4ut/bTPjWQWJMWgyTiiy67noAIR BgKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=82JMUvyYl2pnxY4EIF3/0Ds1qlJ2yc9NiH+iYjuEbcA=; b=pfwUITjP+lLzVthuRnK/TcH5mguhr0acJBmHAmZa52jci0z1Gybz1cqxIVhAEjmKAZ +q/fzt71GpuIfOKKmH+prswuq8OPUClu83CPceFSISdcEeSb/88C/qNzSCy70Sx9Acn7 iwqYBz4qEtR5Mft+rCfvgeJ8w2XDen4MKBugAtGNzy7/Ui/pXXvwCjlVUh2BBYcR15Pt AfcpeCWIWP/fKwnj6tD58orbIxICSluVtQZeFbBuogk1G/6diKLhJgkyK8vd3/ZtykeM U488qJ+D7ZlhvSeJaI22J5eUSnCifMolf0hFuLhMg4UGDJr4evTEYv290WJd6q7aOgCb hmTg== X-Gm-Message-State: APjAAAWz8+O++07SfqyNk/gQb7ZLoQSg28aAXEgfswUzFQ3nCxOo7YCi r7Kj7At9+qc8UK7lWFY9JCmPpR25 X-Google-Smtp-Source: APXvYqwHbFplqG8FjUcMDWWBsURvpVaclWbZghbO2LLgR+EfL6yjqJklwZg5Dvtn0f4XrqcfqhlN5A== X-Received: by 2002:a17:902:7885:: with SMTP id q5mr61096377pll.12.1555111588694; Fri, 12 Apr 2019 16:26:28 -0700 (PDT) Received: from localhost.localdomain.localdomain ([216.113.160.77]) by smtp.gmail.com with ESMTPSA id o68sm105570138pfi.140.2019.04.12.16.26.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Apr 2019 16:26:28 -0700 (PDT) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Fri, 12 Apr 2019 16:26:27 -0700 Message-Id: <1555111588-79659-8-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1555111588-79659-1-git-send-email-hzhou8@ebay.com> References: <1555111588-79659-1-git-send-email-hzhou8@ebay.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 8/9] raft.c: cmd->eid should always be non-null. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Han Zhou raft_command's eid should always be non-null in all 3 cases. Fix the comment, and also replace if condition with assert. Signed-off-by: Han Zhou --- v1->v2: moved the member under "All cases" section, according to Ben's suggestion. ovsdb/raft.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ovsdb/raft.c b/ovsdb/raft.c index abcc9c0..02bdf11 100644 --- a/ovsdb/raft.c +++ b/ovsdb/raft.c @@ -108,13 +108,11 @@ struct raft_command { struct hmap_node hmap_node; /* In struct raft's 'commands' hmap. */ unsigned int n_refs; /* Reference count. */ enum raft_command_status status; /* Execution status. */ + struct uuid eid; /* Entry ID of result. */ /* Case 1 only. */ uint64_t index; /* Index in log (0 if being relayed). */ - /* Cases 2 and 3. */ - struct uuid eid; /* Entry ID of result. */ - /* Case 2 only. */ long long int timestamp; /* Issue or last ping time, for expiration. */ @@ -1974,9 +1972,8 @@ raft_command_initiate(struct raft *raft, } struct raft_command *cmd = raft_command_create_incomplete(raft, index); - if (eid) { - cmd->eid = *eid; - } + ovs_assert(eid); + cmd->eid = *eid; raft_waiter_create(raft, RAFT_W_ENTRY, true)->entry.index = cmd->index;