From patchwork Sat Oct 2 02:31:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 66545 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A5307B70D4 for ; Sat, 2 Oct 2010 12:40:01 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754623Ab0JBCj5 (ORCPT ); Fri, 1 Oct 2010 22:39:57 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:46516 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752103Ab0JBCj4 (ORCPT ); Fri, 1 Oct 2010 22:39:56 -0400 Received: from ayumi.akashicho.tokyo.vergenet.net (219-109-213-121.bitcat.net [219.109.213.121]) by kirsty.vergenet.net (Postfix) with ESMTP id DFD4E24051; Sat, 2 Oct 2010 12:39:54 +1000 (EST) Received: by ayumi.akashicho.tokyo.vergenet.net (Postfix, from userid 7100) id 79B98EDE0E5; Sat, 2 Oct 2010 11:39:52 +0900 (JST) Message-Id: <20101002023315.074179790@akiko.akashicho.tokyo.vergenet.net> User-Agent: quilt/0.48-1 Date: Sat, 02 Oct 2010 11:31:02 +0900 From: Simon Horman To: lvs-devel@vger.kernel.org, netdev@vger.kernel.org, netfilter@vger.kernel.org, netfilter-devel@vger.kernel.org Cc: Jan Engelhardt , Stephen Hemminger , Wensong Zhang , Julian Anastasov , Patrick McHardy Subject: [patch v3 06/12] IPVS: ip_vs_{un,}bind_scheduler NULL arguments References: <20101002023056.536217499@akiko.akashicho.tokyo.vergenet.net> Content-Disposition: inline; filename=0006-IPVS-ip_vs_-un-bind_scheduler-NULL-arguments.patch Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In general NULL arguments aren't passed by the few callers that exist, so don't test for them. The exception is to make passing NULL to ip_vs_unbind_scheduler() a noop. Signed-off-by: Simon Horman v2 * Trivial rediff v3 * Trivial rediff --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: lvs-test-2.6/net/netfilter/ipvs/ip_vs_ctl.c =================================================================== --- lvs-test-2.6.orig/net/netfilter/ipvs/ip_vs_ctl.c 2010-10-02 10:15:45.000000000 +0900 +++ lvs-test-2.6/net/netfilter/ipvs/ip_vs_ctl.c 2010-10-02 10:15:47.000000000 +0900 @@ -1206,8 +1206,7 @@ ip_vs_add_service(struct ip_vs_service_u out_err: if (svc != NULL) { - if (svc->scheduler) - ip_vs_unbind_scheduler(svc); + ip_vs_unbind_scheduler(svc); if (svc->inc) { local_bh_disable(); ip_vs_app_inc_put(svc->inc); Index: lvs-test-2.6/net/netfilter/ipvs/ip_vs_sched.c =================================================================== --- lvs-test-2.6.orig/net/netfilter/ipvs/ip_vs_sched.c 2010-10-02 10:15:45.000000000 +0900 +++ lvs-test-2.6/net/netfilter/ipvs/ip_vs_sched.c 2010-10-02 10:15:47.000000000 +0900 @@ -46,15 +46,6 @@ int ip_vs_bind_scheduler(struct ip_vs_se { int ret; - if (svc == NULL) { - pr_err("%s(): svc arg NULL\n", __func__); - return -EINVAL; - } - if (scheduler == NULL) { - pr_err("%s(): scheduler arg NULL\n", __func__); - return -EINVAL; - } - svc->scheduler = scheduler; if (scheduler->init_service) { @@ -74,18 +65,10 @@ int ip_vs_bind_scheduler(struct ip_vs_se */ int ip_vs_unbind_scheduler(struct ip_vs_service *svc) { - struct ip_vs_scheduler *sched; + struct ip_vs_scheduler *sched = svc->scheduler; - if (svc == NULL) { - pr_err("%s(): svc arg NULL\n", __func__); - return -EINVAL; - } - - sched = svc->scheduler; - if (sched == NULL) { - pr_err("%s(): svc isn't bound\n", __func__); - return -EINVAL; - } + if (!sched) + return 0; if (sched->done_service) { if (sched->done_service(svc) != 0) {