From patchwork Tue Aug 25 15:26:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 52698 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 4B86422E8F for ; Tue, 25 Aug 2015 15:28:21 +0000 (UTC) Received: by lbcli1 with SMTP id li1sf52579457lbc.2 for ; Tue, 25 Aug 2015 08:28:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=zY6w3y65wi008JcqYXBRP9zyWftEJpBkKLfD3eTEeOE=; b=mUFMluPSw8ZRZDcWLo54dc+lcLTx7j6WewsJwv8vq1x1UNhKuXfEpRwr0QSRKuvIM6 3OFrryRfE2X6rE6CPXC9dnpTiFdnCl+O6MsnW+lLYi9Uy4fU0AknysSLKX+kvcubXaGW hRqaWbhiRpvXhK2ZT1bEcXrUtvfn/BlRpgz0/kSz4WUSU8aPmKUMJY7zIBpXba46ssv4 0DaJQGQVlofYmd81BPEoWq2JLifHz4CwLS+KDntJDaGJ2EjpKk96i2OSTzNAsfObx3+n vwtnpZTZr5mhz0SYVMgEpLNPE5WNdTNwuUeOUgDP5yK30GeAJx2Yxc25SvFAFmQgivCh l43A== X-Gm-Message-State: ALoCoQlLiaaoiGzyFvV6Vrs9X/yBG5pro9SOkhwM5juwTO4tP9ZNjM36oVTu19a+Hm65G1fWP3+z X-Received: by 10.112.170.67 with SMTP id ak3mr8576987lbc.6.1440516500271; Tue, 25 Aug 2015 08:28:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.133 with SMTP id v5ls717472lae.63.gmail; Tue, 25 Aug 2015 08:28:19 -0700 (PDT) X-Received: by 10.152.243.9 with SMTP id wu9mr23449432lac.41.1440516499954; Tue, 25 Aug 2015 08:28:19 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id uj8si16286806lbb.22.2015.08.25.08.28.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Aug 2015 08:28:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbbsx3 with SMTP id sx3so102094098lbb.0 for ; Tue, 25 Aug 2015 08:28:19 -0700 (PDT) X-Received: by 10.112.125.34 with SMTP id mn2mr23570020lbb.76.1440516499780; Tue, 25 Aug 2015 08:28:19 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.162.200 with SMTP id yc8csp3256499lbb; Tue, 25 Aug 2015 08:28:18 -0700 (PDT) X-Received: by 10.55.25.94 with SMTP id k91mr47313720qkh.51.1440516497411; Tue, 25 Aug 2015 08:28:17 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d93si29069403qkh.88.2015.08.25.08.28.13; Tue, 25 Aug 2015 08:28:17 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 3169961F3F; Tue, 25 Aug 2015 15:28:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id CA7C361F1C; Tue, 25 Aug 2015 15:27:08 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 65FDA61F12; Tue, 25 Aug 2015 15:26:58 +0000 (UTC) Received: from mail-qk0-f180.google.com (mail-qk0-f180.google.com [209.85.220.180]) by lists.linaro.org (Postfix) with ESMTPS id 630D961CC5 for ; Tue, 25 Aug 2015 15:26:52 +0000 (UTC) Received: by qkda128 with SMTP id a128so52569975qkd.3 for ; Tue, 25 Aug 2015 08:26:52 -0700 (PDT) X-Received: by 10.55.201.220 with SMTP id m89mr43568002qkl.87.1440516412125; Tue, 25 Aug 2015 08:26:52 -0700 (PDT) Received: from localhost.localdomain (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by smtp.gmail.com with ESMTPSA id z71sm13994853qkz.16.2015.08.25.08.26.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Aug 2015 08:26:51 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Tue, 25 Aug 2015 11:26:41 -0400 Message-Id: <1440516404-4177-3-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1440516404-4177-1-git-send-email-mike.holmes@linaro.org> References: <1440516404-4177-1-git-send-email-mike.holmes@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 3/6] linux-generic: fix comparison to NULL X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mike.holmes@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Checkpatch requires that: (entry == NULL) be written (!entry) (entry != NULL) be written (entry) Signed-off-by: Mike Holmes --- platform/linux-generic/odp_classification.c | 54 ++++++++++++++--------------- platform/linux-generic/odp_crypto.c | 2 +- platform/linux-generic/odp_errno.c | 2 +- platform/linux-generic/odp_init.c | 6 ++-- platform/linux-generic/odp_packet.c | 16 ++++----- platform/linux-generic/odp_packet_io.c | 28 +++++++-------- platform/linux-generic/odp_pool.c | 16 ++++----- platform/linux-generic/odp_queue.c | 16 ++++----- platform/linux-generic/odp_schedule.c | 2 +- platform/linux-generic/odp_shared_memory.c | 6 ++-- platform/linux-generic/odp_system_info.c | 14 ++++---- platform/linux-generic/odp_thread.c | 2 +- platform/linux-generic/odp_timer.c | 2 +- 13 files changed, 83 insertions(+), 83 deletions(-) diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 452631a..66e2049 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -62,7 +62,7 @@ int odp_classification_init_global(void) } cos_tbl = odp_shm_addr(cos_shm); - if (cos_tbl == NULL) + if (!cos_tbl) goto error_cos; memset(cos_tbl, 0, sizeof(cos_tbl_t)); @@ -83,7 +83,7 @@ int odp_classification_init_global(void) } pmr_tbl = odp_shm_addr(pmr_shm); - if (pmr_tbl == NULL) + if (!pmr_tbl) goto error_pmr; memset(pmr_tbl, 0, sizeof(pmr_tbl_t)); @@ -104,7 +104,7 @@ int odp_classification_init_global(void) } pmr_set_tbl = odp_shm_addr(pmr_set_shm); - if (pmr_set_tbl == NULL) + if (!pmr_set_tbl) goto error_pmrset; memset(pmr_set_tbl, 0, sizeof(pmr_set_tbl_t)); @@ -267,7 +267,7 @@ int odp_cos_set_queue(odp_cos_t cos_id, odp_queue_t queue_id) { cos_t *cos = get_cos_entry(cos_id); - if (cos == NULL) { + if (!cos) { ODP_ERR("Invalid odp_cos_t handle"); return -1; } @@ -281,7 +281,7 @@ int odp_cos_set_drop(odp_cos_t cos_id, odp_drop_e drop_policy) { cos_t *cos = get_cos_entry(cos_id); - if (cos == NULL) { + if (!cos) { ODP_ERR("Invalid odp_cos_t handle"); return -1; } @@ -297,12 +297,12 @@ int odp_pktio_default_cos_set(odp_pktio_t pktio_in, odp_cos_t default_cos) cos_t *cos; entry = get_pktio_entry(pktio_in); - if (entry == NULL) { + if (!entry) { ODP_ERR("Invalid odp_pktio_t handle"); return -1; } cos = get_cos_entry(default_cos); - if (cos == NULL) { + if (!cos) { ODP_ERR("Invalid odp_cos_t handle"); return -1; } @@ -317,13 +317,13 @@ int odp_pktio_error_cos_set(odp_pktio_t pktio_in, odp_cos_t error_cos) cos_t *cos; entry = get_pktio_entry(pktio_in); - if (entry == NULL) { + if (!entry) { ODP_ERR("Invalid odp_pktio_t handle"); return -1; } cos = get_cos_entry(error_cos); - if (cos == NULL) { + if (!cos) { ODP_ERR("Invalid odp_cos_t handle"); return -1; } @@ -336,7 +336,7 @@ int odp_pktio_skip_set(odp_pktio_t pktio_in, uint32_t offset) { pktio_entry_t *entry = get_pktio_entry(pktio_in); - if (entry == NULL) { + if (!entry) { ODP_ERR("Invalid odp_cos_t handle"); return -1; } @@ -349,7 +349,7 @@ int odp_pktio_headroom_set(odp_pktio_t pktio_in, uint32_t headroom) { pktio_entry_t *entry = get_pktio_entry(pktio_in); - if (entry == NULL) { + if (!entry) { ODP_ERR("Invalid odp_pktio_t handle"); return -1; } @@ -367,7 +367,7 @@ int odp_cos_with_l2_priority(odp_pktio_t pktio_in, cos_t *cos; pktio_entry_t *entry = get_pktio_entry(pktio_in); - if (entry == NULL) { + if (!entry) { ODP_ERR("Invalid odp_pktio_t handle"); return -1; } @@ -377,7 +377,7 @@ int odp_cos_with_l2_priority(odp_pktio_t pktio_in, /* Update the L2 QoS table*/ for (i = 0; i < num_qos; i++) { cos = get_cos_entry(cos_table[i]); - if (cos != NULL) { + if (cos) { if (ODP_COS_MAX_L2_QOS > qos_table[i]) l2_cos->cos[qos_table[i]] = cos; } @@ -397,7 +397,7 @@ int odp_cos_with_l3_qos(odp_pktio_t pktio_in, pktio_entry_t *entry = get_pktio_entry(pktio_in); cos_t *cos; - if (entry == NULL) { + if (!entry) { ODP_ERR("Invalid odp_pktio_t handle"); return -1; } @@ -409,7 +409,7 @@ int odp_cos_with_l3_qos(odp_pktio_t pktio_in, /* Update the L3 QoS table*/ for (i = 0; i < num_qos; i++) { cos = get_cos_entry(cos_table[i]); - if (cos != NULL) { + if (cos) { if (ODP_COS_MAX_L3_QOS > qos_table[i]) l3_cos->cos[qos_table[i]] = cos; } @@ -449,7 +449,7 @@ int odp_pmr_destroy(odp_pmr_t pmr_id) { pmr_t *pmr = get_pmr_entry(pmr_id); - if (pmr == NULL) + if (!pmr) return -1; pmr->s.valid = 0; return 0; @@ -465,19 +465,19 @@ int odp_pktio_pmr_cos(odp_pmr_t pmr_id, cos_t *cos; pktio_entry = get_pktio_entry(src_pktio); - if (pktio_entry == NULL) { + if (!pktio_entry) { ODP_ERR("Invalid odp_pktio_t handle"); return -1; } pmr = get_pmr_entry(pmr_id); - if (pmr == NULL) { + if (!pmr) { ODP_ERR("Invalid odp_pmr_t handle"); return -1; } cos = get_cos_entry(dst_cos); - if (cos == NULL) { + if (!cos) { ODP_ERR("Invalid odp_cos_t handle"); return -1; } @@ -585,7 +585,7 @@ int odp_pmr_match_set_destroy(odp_pmr_set_t pmr_set_id) { pmr_set_t *pmr_set = get_pmr_set_entry(pmr_set_id); - if (pmr_set == NULL) + if (!pmr_set) return -1; pmr_set->s.pmr.s.valid = 0; @@ -601,19 +601,19 @@ int odp_pktio_pmr_match_set_cos(odp_pmr_set_t pmr_set_id, odp_pktio_t src_pktio, cos_t *cos; pktio_entry = get_pktio_entry(src_pktio); - if (pktio_entry == NULL) { + if (!pktio_entry) { ODP_ERR("Invalid odp_pktio_t handle"); return -1; } pmr = (pmr_t *)get_pmr_set_entry(pmr_set_id); - if (pmr == NULL) { + if (!pmr) { ODP_ERR("Invalid odp_pmr_set_t handle"); return -1; } cos = get_cos_entry(dst_cos); - if (cos == NULL) { + if (!cos) { ODP_ERR("Invalid odp_cos_t handle"); return -1; } @@ -750,7 +750,7 @@ cos_t *match_pmr_cos(cos_t *cos, uint8_t *pkt_addr, pmr_t *pmr, { cos_t *retcos = NULL; - if (cos == NULL || pmr == NULL) + if (!cos || !pmr) return NULL; if (!cos->s.valid) @@ -773,7 +773,7 @@ int pktio_classifier_init(pktio_entry_t *entry) int i; /* classifier lock should be acquired by the calling function */ - if (entry == NULL) + if (!entry) return -1; cls = &entry->s.cls; cls->num_pmr = 0; @@ -800,7 +800,7 @@ int packet_classifier(odp_pktio_t pktio, odp_packet_t pkt) uint8_t *pkt_addr; entry = get_pktio_entry(pktio); - if (entry == NULL) + if (!entry) return -1; pkt_hdr = odp_packet_hdr(pkt); @@ -808,7 +808,7 @@ int packet_classifier(odp_pktio_t pktio, odp_packet_t pkt) /* Matching PMR and selecting the CoS for the packet*/ cos = pktio_select_cos(entry, pkt_addr, pkt_hdr); - if (cos == NULL) + if (!cos) return -1; /* Enqueuing the Packet based on the CoS */ diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 9384291..f073aa8 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -452,7 +452,7 @@ int odp_crypto_term_global(void) int count = 0; odp_crypto_generic_session_t *session; - for (session = global->free; session != NULL; session = session->next) + for (session = global->free; session; session = session->next) count++; if (count != MAX_SESSIONS) { ODP_ERR("crypto sessions still active\n"); diff --git a/platform/linux-generic/odp_errno.c b/platform/linux-generic/odp_errno.c index 1a76d43..5d2f0ea 100644 --- a/platform/linux-generic/odp_errno.c +++ b/platform/linux-generic/odp_errno.c @@ -24,7 +24,7 @@ void odp_errno_zero(void) void odp_errno_print(const char *str) { - if (str != NULL) + if (str) printf("%s ", str); ODP_PRINT("%s\n", strerror(__odp_errno)); diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 2bfabb6..6b4497c 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -17,10 +17,10 @@ int odp_init_global(odp_init_t *params, odp_global_data.log_fn = odp_override_log; odp_global_data.abort_fn = odp_override_abort; - if (params != NULL) { - if (params->log_fn != NULL) + if (params) { + if (params->log_fn) odp_global_data.log_fn = params->log_fn; - if (params->abort_fn != NULL) + if (params->abort_fn) odp_global_data.abort_fn = params->abort_fn; } diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index bdd84a8..fc848f9 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -193,7 +193,7 @@ void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len, odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); void *addr = packet_map(pkt_hdr, offset, len); - if (addr != NULL && seg != NULL) { + if (addr && seg) { odp_buffer_bits_t seghandle; seghandle.handle = (odp_buffer_t)pkt; @@ -440,8 +440,8 @@ odp_packet_t odp_packet_add_data(odp_packet_t pkt, uint32_t offset, new_hdr->input = pkt_hdr->input; new_hdr->buf_hdr.buf_u64 = pkt_hdr->buf_hdr.buf_u64; - if (new_hdr->buf_hdr.uarea_addr != NULL && - pkt_hdr->buf_hdr.uarea_addr != NULL) + if (new_hdr->buf_hdr.uarea_addr && + pkt_hdr->buf_hdr.uarea_addr) memcpy(new_hdr->buf_hdr.uarea_addr, pkt_hdr->buf_hdr.uarea_addr, new_hdr->buf_hdr.uarea_size <= @@ -485,8 +485,8 @@ odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset, new_hdr->input = pkt_hdr->input; new_hdr->buf_hdr.buf_u64 = pkt_hdr->buf_hdr.buf_u64; - if (new_hdr->buf_hdr.uarea_addr != NULL && - pkt_hdr->buf_hdr.uarea_addr != NULL) + if (new_hdr->buf_hdr.uarea_addr && + pkt_hdr->buf_hdr.uarea_addr) memcpy(new_hdr->buf_hdr.uarea_addr, pkt_hdr->buf_hdr.uarea_addr, new_hdr->buf_hdr.uarea_size <= @@ -630,7 +630,7 @@ int odp_packet_is_valid(odp_packet_t pkt) { odp_buffer_hdr_t *buf = validate_buf((odp_buffer_t)pkt); - return (buf != NULL && buf->type == ODP_EVENT_PACKET); + return (buf && buf->type == ODP_EVENT_PACKET); } /* @@ -647,8 +647,8 @@ void _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, odp_packet_t dstpkt) dsthdr->input = srchdr->input; dsthdr->buf_hdr.buf_u64 = srchdr->buf_hdr.buf_u64; - if (dsthdr->buf_hdr.uarea_addr != NULL && - srchdr->buf_hdr.uarea_addr != NULL) + if (dsthdr->buf_hdr.uarea_addr && + srchdr->buf_hdr.uarea_addr) memcpy(dsthdr->buf_hdr.uarea_addr, srchdr->buf_hdr.uarea_addr, dsthdr->buf_hdr.uarea_size <= diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 2c7240e..1a8d3fb 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -44,7 +44,7 @@ int odp_pktio_init_global(void) sizeof(pktio_entry_t), 0); pktio_tbl = odp_shm_addr(shm); - if (pktio_tbl == NULL) + if (!pktio_tbl) return -1; memset(pktio_tbl, 0, sizeof(pktio_table_t)); @@ -188,7 +188,7 @@ static int free_pktio_entry(odp_pktio_t id) { pktio_entry_t *entry = get_pktio_entry(id); - if (entry == NULL) + if (!entry) return -1; set_free(entry); @@ -269,7 +269,7 @@ int odp_pktio_close(odp_pktio_t id) int res = -1; entry = get_pktio_entry(id); - if (entry == NULL) + if (!entry) return -1; lock_entry(entry); @@ -321,7 +321,7 @@ int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], int len) int pkts; int i; - if (pktio_entry == NULL) + if (!pktio_entry) return -1; lock_entry(pktio_entry); @@ -342,7 +342,7 @@ int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], int len) pktio_entry_t *pktio_entry = get_pktio_entry(id); int pkts; - if (pktio_entry == NULL) + if (!pktio_entry) return -1; lock_entry(pktio_entry); @@ -357,7 +357,7 @@ int odp_pktio_inq_setdef(odp_pktio_t id, odp_queue_t queue) pktio_entry_t *pktio_entry = get_pktio_entry(id); queue_entry_t *qentry; - if (pktio_entry == NULL || queue == ODP_QUEUE_INVALID) + if (!pktio_entry || queue == ODP_QUEUE_INVALID) return -1; qentry = queue_to_qentry(queue); @@ -400,7 +400,7 @@ int odp_pktio_inq_remdef(odp_pktio_t id) odp_queue_t queue; queue_entry_t *qentry; - if (pktio_entry == NULL) + if (!pktio_entry) return -1; lock_entry(pktio_entry); @@ -421,7 +421,7 @@ odp_queue_t odp_pktio_inq_getdef(odp_pktio_t id) { pktio_entry_t *pktio_entry = get_pktio_entry(id); - if (pktio_entry == NULL) + if (!pktio_entry) return ODP_QUEUE_INVALID; return pktio_entry->s.inq_default; @@ -431,7 +431,7 @@ odp_queue_t odp_pktio_outq_getdef(odp_pktio_t id) { pktio_entry_t *pktio_entry = get_pktio_entry(id); - if (pktio_entry == NULL) + if (!pktio_entry) return ODP_QUEUE_INVALID; return pktio_entry->s.outq_default; @@ -491,7 +491,7 @@ odp_buffer_hdr_t *pktin_dequeue(queue_entry_t *qentry) int pkts, i, j; buf_hdr = queue_deq(qentry); - if (buf_hdr != NULL) + if (buf_hdr) return buf_hdr; pkts = odp_pktio_recv(qentry->s.pktin, pkt_tbl, QUEUE_MULTI_MAX); @@ -608,7 +608,7 @@ int odp_pktio_mtu(odp_pktio_t id) int ret; entry = get_pktio_entry(id); - if (entry == NULL) { + if (!entry) { ODP_DBG("pktio entry %d does not exist\n", id); return -1; } @@ -632,7 +632,7 @@ int odp_pktio_promisc_mode_set(odp_pktio_t id, odp_bool_t enable) int ret; entry = get_pktio_entry(id); - if (entry == NULL) { + if (!entry) { ODP_DBG("pktio entry %d does not exist\n", id); return -1; } @@ -657,7 +657,7 @@ int odp_pktio_promisc_mode(odp_pktio_t id) int ret; entry = get_pktio_entry(id); - if (entry == NULL) { + if (!entry) { ODP_DBG("pktio entry %d does not exist\n", id); return -1; } @@ -687,7 +687,7 @@ int odp_pktio_mac_addr(odp_pktio_t id, void *mac_addr, int addr_size) } entry = get_pktio_entry(id); - if (entry == NULL) { + if (!entry) { ODP_DBG("pktio entry %d does not exist\n", id); return -1; } diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 79100a1..dc12887 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -66,7 +66,7 @@ int odp_pool_init_global(void) pool_tbl = odp_shm_addr(shm); - if (pool_tbl == NULL) + if (!pool_tbl) return -1; memset(pool_tbl, 0, sizeof(pool_table_t)); @@ -147,7 +147,7 @@ odp_pool_t odp_pool_create(const char *name, odp_pool_param_t *params) uint32_t i, headroom = 0, tailroom = 0; odp_shm_t shm; - if (params == NULL) + if (!params) return ODP_POOL_INVALID; /* Default size and align for timeouts */ @@ -253,7 +253,7 @@ odp_pool_t odp_pool_create(const char *name, odp_pool_param_t *params) pool->s.flags.all = 0; - if (name == NULL) { + if (!name) { pool->s.name[0] = 0; } else { strncpy(pool->s.name, name, ODP_POOL_NAME_LEN - 1); @@ -423,7 +423,7 @@ int odp_pool_info(odp_pool_t pool_hdl, odp_pool_info_t *info) uint32_t pool_id = pool_handle_to_index(pool_hdl); pool_entry_t *pool = get_pool_entry(pool_id); - if (pool == NULL || info == NULL) + if (!pool || !info) return -1; info->name = pool->s.name; @@ -437,7 +437,7 @@ int odp_pool_destroy(odp_pool_t pool_hdl) uint32_t pool_id = pool_handle_to_index(pool_hdl); pool_entry_t *pool = get_pool_entry(pool_id); - if (pool == NULL) + if (!pool) return -1; POOL_LOCK(&pool->s.lock); @@ -482,10 +482,10 @@ odp_buffer_t buffer_alloc(odp_pool_t pool_hdl, size_t size) &pool->s, totsize); /* If cache is empty, satisfy request from the pool */ - if (odp_unlikely(buf == NULL)) { + if (odp_unlikely(!buf)) { buf = (odp_anybuf_t *)(void *)get_buf(&pool->s); - if (odp_unlikely(buf == NULL)) + if (odp_unlikely(!buf)) return ODP_BUFFER_INVALID; /* Get blocks for this buffer, if pool uses application data */ @@ -495,7 +495,7 @@ odp_buffer_t buffer_alloc(odp_pool_t pool_hdl, size_t size) do { uint8_t *blk = get_blk(&pool->s); - if (blk == NULL) { + if (!blk) { ret_buf(&pool->s, &buf->buf); return ODP_BUFFER_INVALID; } diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 2cbcac2..01b39c5 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -103,7 +103,7 @@ int odp_queue_init_global(void) queue_tbl = odp_shm_addr(shm); - if (queue_tbl == NULL) + if (!queue_tbl) return -1; memset(queue_tbl, 0, sizeof(queue_table_t)); @@ -257,7 +257,7 @@ int odp_queue_destroy(odp_queue_t handle) ODP_ERR("queue \"%s\" already destroyed\n", queue->s.name); return -1; } - if (queue->s.head != NULL) { + if (queue->s.head) { UNLOCK(&queue->s.lock); ODP_ERR("queue \"%s\" not empty\n", queue->s.name); return -1; @@ -335,7 +335,7 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr) return -1; } - if (queue->s.head == NULL) { + if (!queue->s.head) { /* Empty queue */ queue->s.head = buf_hdr; queue->s.tail = buf_hdr; @@ -379,7 +379,7 @@ int queue_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num) } /* Empty queue */ - if (queue->s.head == NULL) + if (!queue->s.head) queue->s.head = buf_hdr[0]; else queue->s.tail->next = buf_hdr[0]; @@ -433,7 +433,7 @@ odp_buffer_hdr_t *queue_deq(queue_entry_t *queue) LOCK(&queue->s.lock); - if (queue->s.head == NULL) { + if (!queue->s.head) { /* Already empty queue */ if (queue->s.status == QUEUE_STATUS_SCHED) queue->s.status = QUEUE_STATUS_NOTSCHED; @@ -446,7 +446,7 @@ odp_buffer_hdr_t *queue_deq(queue_entry_t *queue) queue->s.head = buf_hdr->next; buf_hdr->next = NULL; - if (queue->s.head == NULL) { + if (!queue->s.head) { /* Queue is now empty */ queue->s.tail = NULL; } @@ -471,7 +471,7 @@ int queue_deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num) hdr = queue->s.head; - if (hdr == NULL) { + if (!hdr) { /* Already empty queue */ if (queue->s.status == QUEUE_STATUS_SCHED) queue->s.status = QUEUE_STATUS_NOTSCHED; @@ -488,7 +488,7 @@ int queue_deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num) queue->s.head = hdr; - if (hdr == NULL) { + if (!hdr) { /* Queue is now empty */ queue->s.tail = NULL; } diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 172d0a0..fc5677c 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -112,7 +112,7 @@ int odp_schedule_init_global(void) sched = odp_shm_addr(shm); - if (sched == NULL) { + if (!sched) { ODP_ERR("Schedule init: Shm reserve failed.\n"); return -1; } diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index 38b0b28..5935e0a 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -113,7 +113,7 @@ static int find_block(const char *name, uint32_t *index) for (i = 0; i < ODP_CONFIG_SHM_BLOCKS; i++) { if (strcmp(name, odp_shm_tbl->block[i].name) == 0) { /* found it */ - if (index != NULL) + if (index) *index = i; return 1; @@ -145,7 +145,7 @@ int odp_shm_free(odp_shm_t shm) block = &odp_shm_tbl->block[i]; - if (block->addr == NULL) { + if (!block->addr) { ODP_DBG("odp_shm_free: Free block\n"); odp_spinlock_unlock(&odp_shm_tbl->lock); return 0; @@ -221,7 +221,7 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, } for (i = 0; i < ODP_CONFIG_SHM_BLOCKS; i++) { - if (odp_shm_tbl->block[i].addr == NULL) { + if (!odp_shm_tbl->block[i].addr) { /* Found free block */ break; } diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 8897832..9e217ff 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -61,12 +61,12 @@ static int systemcpu_cache_line_size(void) int size = 0; file = fopen(CACHE_LNSZ_FILE, "rt"); - if (file == NULL) { + if (!file) { /* File not found */ return 0; } - if (fgets(str, sizeof(str), file) != NULL) { + if (fgets(str, sizeof(str), file)) { /* Read cache line size */ if (!sscanf(str, "%i", &size) == EOF) { ODP_ERR("failed to read chche line size\n"); @@ -87,7 +87,7 @@ static int huge_page_size(void) int size = 0; dir = opendir(HUGE_PAGE_DIR); - if (dir == NULL) { + if (!dir) { ODP_ERR("%s not found\n", HUGE_PAGE_DIR); return 0; } @@ -122,7 +122,7 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo) int model = 0; int count = 2; - while (fgets(str, sizeof(str), file) != NULL && count > 0) { + while (fgets(str, sizeof(str), file) && count > 0) { if (!mhz) { pos = strstr(str, "cpu MHz"); if (pos) { @@ -170,7 +170,7 @@ static int cpuinfo_octeon(FILE *file, odp_system_info_t *sysinfo) int model = 0; int count = 2; - while (fgets(str, sizeof(str), file) != NULL && count > 0) { + while (fgets(str, sizeof(str), file) && count > 0) { if (!mhz) { pos = strstr(str, "BogoMIPS"); @@ -211,7 +211,7 @@ static int cpuinfo_powerpc(FILE *file, odp_system_info_t *sysinfo) int model = 0; int count = 2; - while (fgets(str, sizeof(str), file) != NULL && count > 0) { + while (fgets(str, sizeof(str), file) && count > 0) { if (!mhz) { pos = strstr(str, "clock"); @@ -344,7 +344,7 @@ int odp_system_info_init(void) odp_global_data.system_info.page_size = ODP_PAGE_SIZE; file = fopen("/proc/cpuinfo", "rt"); - if (file == NULL) { + if (!file) { ODP_ERR("Failed to open /proc/cpuinfo\n"); return -1; } diff --git a/platform/linux-generic/odp_thread.c b/platform/linux-generic/odp_thread.c index 13c5ff2..c1e71e4 100644 --- a/platform/linux-generic/odp_thread.c +++ b/platform/linux-generic/odp_thread.c @@ -55,7 +55,7 @@ int odp_thread_init_global(void) thread_globals = odp_shm_addr(shm); - if (thread_globals == NULL) + if (!thread_globals) return -1; memset(thread_globals, 0, sizeof(thread_globals_t)); diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 45074cc..e90bbed 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -357,7 +357,7 @@ static bool timer_reset(uint32_t idx, bool success = true; tick_buf_t *tb = &tp->tick_buf[idx]; - if (tmo_buf == NULL || *tmo_buf == ODP_BUFFER_INVALID) { + if (!tmo_buf || *tmo_buf == ODP_BUFFER_INVALID) { #ifdef ODP_ATOMIC_U128 tick_buf_t new, old;