[PATCH] staging: rdma: hfi1: diag: constify hfi1_filter_array structure

2015-12-23 Thread Julia Lawall
The hfi1_filter_array structure is never modified, so declare it as const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall --- drivers/staging/rdma/hfi1/diag.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rdma/hfi1/diag.c b/drivers

[PATCH] i40iw: fix compare_const_fl.cocci warnings

2015-12-22 Thread Julia Lawall
Move constants to the right of binary operators. Generated by: scripts/coccinelle/misc/compare_const_fl.cocci CC: Faisal Latif Signed-off-by: Fengguang Wu Signed-off-by: Julia Lawall --- It's a minor point, but when I first looked at the code, I thought that MIN and MAX were inverte

Re: [Cocci] [PATCH] staging/rdma/hfi1: Fix a possible null pointer dereference

2015-12-20 Thread Julia Lawall
give a false positive when the dereference is an argument of sizeof, or //# when the value is passed to another function that returns an error code. /// // Confidence: Moderate // Copyright: (C) 2015 Julia Lawall, Inria. GPLv2. // URL: http://coccinelle.lip6.fr/ // Options: --no-includes --include

[PATCH] IB/usnic: delete unneeded IS_ERR test

2015-12-19 Thread Julia Lawall
kzalloc doesn't return ERR_PTR, so there is no need to test for it. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression x,e; @@ * x = kzalloc(...) ... when != x = e * IS_ERR_OR_NULL(x) // Signed-off-by: Julia Lawall --- dr

Re: [Cocci] [PATCH] staging/rdma/hfi1: Fix a possible null pointer dereference

2015-12-17 Thread Julia Lawall
On Mon, 14 Dec 2015, Nicholas Mc Guire wrote: > On Thu, Dec 10, 2015 at 11:13:38AM -0500, Mike Marciniszyn wrote: > > From: Easwar Hariharan > > > > A code inspection pointed out that kmalloc_array may return NULL and > > memset doesn't check the input pointer for NULL, resulting in a possible

[PATCH 3/3] IB/core: constify mmu_notifier_ops structures

2015-11-29 Thread Julia Lawall
This mmu_notifier_ops structure is never modified, so declare it as const, like the other mmu_notifier_ops structures. Done with the help of Coccinelle. Signed-off-by: Julia Lawall --- The patches in this series are independent of each other. drivers/infiniband/core/umem_odp.c |2 +- 1

[PATCH 0/3] constify mmu_notifier_ops structures

2015-11-29 Thread Julia Lawall
mmu_notifier_ops structures are never modified, so declare them all as const. --- drivers/infiniband/core/umem_odp.c |2 +- drivers/iommu/amd_iommu_v2.c |2 +- drivers/xen/gntdev.c |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) -- To unsubscribe from this

[PATCH] IB/iser: constify iser_reg_ops structure

2015-11-28 Thread Julia Lawall
The iser_reg_ops structures are never modified, so declare them as const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall --- drivers/infiniband/ulp/iser/iscsi_iser.h |2 +- drivers/infiniband/ulp/iser/iser_memory.c |4 ++-- 2 files changed, 3 insertions(+), 3 deletions

[PATCH] RDMA/nes: constify nes_cm_ops structure

2015-11-28 Thread Julia Lawall
The nes_cm_ops structure is never modified, so declare it as const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall --- drivers/infiniband/hw/nes/nes_cm.c |2 +- drivers/infiniband/hw/nes/nes_cm.h |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a

Re: [patch] IB/hfi1: info leak in get_ctxt_info()

2015-09-15 Thread Julia Lawall
On Wed, 16 Sep 2015, Dan Carpenter wrote: > The cinfo struct has a hole after the last struct member so we need to > zero it out. Otherwise we don't disclose some uninitialized stack data. I think the "don't" wasn't intended in the second sentence? julia > > Signed-off-by: Dan Carpenter > >

[PATCH 11/39] hfi1: drop null test before destroy functions

2015-09-13 Thread Julia Lawall
Remove unneeded NULL test. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression x; @@ -if (x != NULL) \(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x); // Signed-off-by: Julia Lawall --- drivers/staging/rdma/hfi1/user_sdma.c

[PATCH 00/39] drop null test before destroy functions

2015-09-13 Thread Julia Lawall
Recent commits to kernel/git/torvalds/linux.git have made the following functions able to tolerate NULL arguments: kmem_cache_destroy (commit 3942d29918522) mempool_destroy (commit 4e3ca3e033d1) dma_pool_destroy (commit 44d7175da6ea) These patches remove the associated NULL tests for the files th

[PATCH 4/9] RDMA/ocrdma: drop unneeded goto

2015-05-28 Thread Julia Lawall
From: Julia Lawall Delete jump to a label on the next line, when that label is not used elsewhere. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @r@ identifier l; @@ -if (...) goto l; -l: // Signed-off-by: Julia Lawall

[PATCH 0/9] drop unneeded goto

2015-05-28 Thread Julia Lawall
These patches drop gotos that jump to a label that is at the next instruction, in the case that the label is not used elsewhere in the function. The complete semantic patch that performs this transformation is as follows: // @r@ position p; identifier l; @@ if (...) goto l@p; l: @script:ocaml

[PATCH 0/16] fix error return code

2015-04-05 Thread Julia Lawall
The complate semantic patch that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @ok exists@ identifier f,ret,i; expression e; constant c; @@ // identify a function that returns a negative return value at least once. f(...) { ... when any ( return -c@i; | ret = -c@i; ... when !

[PATCH 12/16] ib_srpt: fix error return code

2015-04-05 Thread Julia Lawall
amp;ret *if(...) { ... when != ret = e2 when forall return ret; } // In the first case, the printk is changed to use the ret value, rather than duplicating PTR_ERR(ch->thread). This requires changing the format from %ld to %d, to account for the type of ret. Signed-off-by: Ju

[PATCH 4/4] cxgb4: Drop unneeded cast on netdev_priv

2015-03-29 Thread Julia Lawall
From: Julia Lawall The result of netdev_priv is already implicitly cast to the type of the left side of the assignment. The semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @@ type T; T *x; @@ x = - (T *) netdev_priv(...) // Signed-off-by: Julia

[PATCH 3/15] net/mlx5_core: don't export static symbol

2015-03-12 Thread Julia Lawall
From: Julia Lawall The semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ type T; identifier f; @@ static T f (...) { ... } @@ identifier r.f; declarer name EXPORT_SYMBOL; @@ -EXPORT_SYMBOL(f); // Signed-off-by: Julia Lawall --- drivers/net

[PATCH 0/15] don't export static symbol

2015-03-11 Thread Julia Lawall
These patches remove EXPORT_SYMBOL or EXPORT_SYMBOL_GPL declarations on static functions. This was done using the following semantic patch: (http://coccinelle.lip6.fr/) // @r@ type T; identifier f; @@ static T f (...) { ... } @@ identifier r.f; declarer name EXPORT_SYMBOL; @@ -EXPORT_SYMBOL(f

Re: [patch] IB/mlx5: fix error code in get_port_caps()

2015-01-12 Thread Julia Lawall
On Mon, 12 Jan 2015, Dan Carpenter wrote: > We should return -ENOMEM on allocation failure instead of success. Probably not a big deal, but the commit message is not clear at all. From the fix, it doesn't look like the code was returning -ENOMEM on success. julia > Fixes: e126ba97dba9 ('mlx5:

[PATCH 0/6] fix error return code

2014-11-22 Thread Julia Lawall
The complate semantic patch that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @ok exists@ identifier f,ret,i; expression e; constant c; @@ // identify a function that returns a negative return value at least once. f(...) { ... when any ( return -c@i; | ret = -c@i; ... when !

[PATCH 5/6] ib_srpt: fix error return code

2014-11-22 Thread Julia Lawall
From: Julia Lawall Return a negative error code on failure. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ identifier ret; expression e1,e2; @@ ( if (\(ret < 0\|ret != 0\)) { ... return ret; } | ret = 0 ) ... when !=

RE: [PATCH 9/10] IB/qib: use safer test on the result of find_first_zero_bit

2014-06-04 Thread Julia Lawall
On Wed, 4 Jun 2014, Marciniszyn, Mike wrote: > > Subject: [PATCH 9/10] IB/qib: use safer test on the result of > > find_first_zero_bit > > > > From: Julia Lawall > > Thanks for the patch! > > Roland, I'm marking this as stable since a memory corru

Re: [PATCH 0/10] use safer test on the result of find_first_zero_bit

2014-06-04 Thread Julia Lawall
On Wed, 4 Jun 2014, Geert Uytterhoeven wrote: > Hi Julia, > > On Wed, Jun 4, 2014 at 1:00 PM, Julia Lawall wrote: > > OK, thanks. I was only looking at the C code. > > > > But the C code contains a loop that is followed by: > > > > if (!

Re: [PATCH 0/10] use safer test on the result of find_first_zero_bit

2014-06-04 Thread Julia Lawall
On Wed, 4 Jun 2014, Geert Uytterhoeven wrote: > Hi Julia, > > On Wed, Jun 4, 2014 at 11:52 AM, Julia Lawall wrote: > >> Maybe the documented return code should be changed to allow for the > >> existing behaviour. > > > > Sorry, I'm not sure to under

RE: [PATCH 0/10] use safer test on the result of find_first_zero_bit

2014-06-04 Thread Julia Lawall
On Wed, 4 Jun 2014, David Laight wrote: > From: Julia Lawall > > On Wed, 4 Jun 2014, Geert Uytterhoeven wrote: > > > > > Hi Julia, > > > > > > On Wed, Jun 4, 2014 at 11:07 AM, Julia Lawall > > > wrote: > > > > Find_firs

Re: [PATCH 0/10] use safer test on the result of find_first_zero_bit

2014-06-04 Thread Julia Lawall
On Wed, 4 Jun 2014, Geert Uytterhoeven wrote: > Hi Julia, > > On Wed, Jun 4, 2014 at 11:07 AM, Julia Lawall wrote: > > Find_first_zero_bit considers BITS_PER_LONG bits at a time, and thus may > > return a larger number than the maximum position argument if that position

[PATCH 0/10] use safer test on the result of find_first_zero_bit

2014-06-04 Thread Julia Lawall
Find_first_zero_bit considers BITS_PER_LONG bits at a time, and thus may return a larger number than the maximum position argument if that position is not a multiple of BITS_PER_LONG. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majord...@vge

[PATCH 9/10] IB/qib: use safer test on the result of find_first_zero_bit

2014-06-04 Thread Julia Lawall
From: Julia Lawall Find_first_zero_bit considers BITS_PER_LONG bits at a time, and thus may return a larger number than the maximum position argument if that position is not a multiple of BITS_PER_LONG. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr

[PATCH 5/25] IB/mlx4: fix error return code

2013-12-29 Thread Julia Lawall
From: Julia Lawall Set the return variable to an error code as done elsewhere in the function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when !=

[PATCH 0/25] fix error return code

2013-12-29 Thread Julia Lawall
These patches fix cases where the return variable is not set to an error code in an error case. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

[PATCH 22/25] RDMA/nes: fix error return code

2013-12-29 Thread Julia Lawall
From: Julia Lawall Set the return variable to an error code as done elsewhere in the function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when !=

[PATCH 14/25] RDMA/amso1100: fix error return code

2013-12-29 Thread Julia Lawall
From: Julia Lawall Set the return variable to an error code as done elsewhere in the function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when !=

[PATCH 14/15] drivers/infiniband/hw/mlx4/sysfs.c: adjust duplicate test

2013-01-21 Thread Julia Lawall
From: Julia Lawall Delete successive tests to the same location. The code tested the result of a previous allocation, that itself was already tested. It is changed to test the result of the most recent allocation. A simplified version of the semantic match that finds this problem is as

merging printk and WARN

2012-11-04 Thread Julia Lawall
It looks like these patches were not a good idea, because in each case the printk provides an error level, and WARN then provides another one. Sorry for the noise. julia -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majord...@vger.kernel.or

[PATCH 6/16] drivers/infiniband/hw/cxgb4/cm.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall Use WARN rather than printk followed by WARN_ON(1), for conciseness. A simplified version of the semantic patch that makes this transformation is as follows: (http://coccinelle.lip6.fr/) // @@ expression list es; @@ -printk( +WARN(1, es); -WARN_ON(1); // Signed-off-by

[PATCH 8/16] drivers/infiniband/hw/cxgb3/iwch_cm.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall Use WARN rather than printk followed by WARN_ON(1), for conciseness. A simplified version of the semantic patch that makes this transformation is as follows: (http://coccinelle.lip6.fr/) // @@ expression list es; @@ -printk( +WARN(1, es); -WARN_ON(1); // Signed-off-by

[PATCH 16/16] drivers/infiniband/hw/nes: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall Use WARN rather than printk followed by WARN_ON(1), for conciseness. A simplified version of the semantic patch that makes this transformation is as follows: (http://coccinelle.lip6.fr/) // @@ expression list es; @@ -printk( +WARN(1, es); -WARN_ON(1); // Signed-off-by

[PATCH 5/5] drivers/infiniband/hw/qib/qib_iba7322.c: fix error return code

2012-08-14 Thread Julia Lawall
From: Julia Lawall Convert a 0 error return code to a negative one, as returned elsewhere in the function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ identifier ret; expression e,e1,e2,e3,e4,x; @@ ( if (\(ret != 0\|ret

[PATCH 1/4] drivers/infiniband/hw/qib/qib_iba6120.c: convert GFP_KERNEL to GFP_ATOMIC

2012-01-09 Thread Julia Lawall
From: Julia Lawall The function is called with locks held and thus should not use GFP_KERNEL. The semantic patch that makes this report is available in scripts/coccinelle/locks/call_kern.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by

[PATCH] drivers/infiniband/hw/nes/nes_verbs.c: add missing calls to ib_umem_release

2011-08-09 Thread Julia Lawall
From: Julia Lawall Add calls to ib_umem_release, as in the other error-handling code in the same function. Signed-off-by: Julia Lawall --- drivers/infiniband/hw/nes/nes_verbs.c |5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b

[PATCH 2/16] drivers/infiniband/hw/cxgb4: Remove unnecessary error code assignment

2010-08-16 Thread Julia Lawall
From: Julia Lawall This code initializes ret to -ENOMEM, but actually ret is not used in the code starting at err7, and -ENOMEM is always returned in this case, so the initialization of ret is unnecessary. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr

[PATCH 4/42] drivers/infiniband/hw/nes: Adjust confusing if indentation

2010-08-05 Thread Julia Lawall
From: Julia Lawall It is not clear whether the assignment should be part of the if branch suggested by its indentation. The patch preserves the current semantics. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r disable braces4@ position p1,p2

[PATCH 9/9] drivers/infiniband/hw/ehca: Drop unnecessary null test

2010-08-03 Thread Julia Lawall
From: Julia Lawall list_for_each_entry binds its first argument to a non-null value, and thus any null test on the value of that argument is superfluous. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ iterator I; expression x; statement S,S1,S2

[PATCH 10/27] drivers/infiniband/core: Use memdup_user

2010-05-22 Thread Julia Lawall
From: Julia Lawall Use memdup_user when user data is immediately copied into the allocated region. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression from,to,size,flag; position p; identifier l1,l2; @@ - to = \(kmal...@p\|kzal...@p\)(size

[PATCH 31/37] drivers/infiniband/core: Use kmemdup

2010-05-15 Thread Julia Lawall
From: Julia Lawall Use kmemdup when some other buffer is immediately copied into the allocated region. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression from,to,size,flag; statement S; @@ - to = \(kmalloc\|kzalloc

RE: [PATCH 3/5] drivers/infiniband: correct size computation

2009-12-07 Thread Julia Lawall
From: Julia Lawall The size argument to ioremap_nocache should be the size of desired information, not the pointer to it. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @expression@ expression *x; @@ x = <+... *sizeof(x) ...+>// Signed-

RE: [PATCH 3/5] drivers/infiniband: correct size computation

2009-12-07 Thread Julia Lawall
On Mon, 7 Dec 2009, Tung, Chien Tin wrote: > >> > /* Remap the PCI registers in adapter BAR0 to kernel VA space */ > >> >- mmio_regs = ioremap_nocache(pci_resource_start(pcidev, BAR_0), > >> >sizeof(mmio_regs)); > >> >+ mmio_regs = ioremap_nocache(pci_resource_start(pcidev, BAR_0), > >> >+

RE: [PATCH 3/5] drivers/infiniband: correct size computation

2009-12-07 Thread Julia Lawall
On Mon, 7 Dec 2009, Tung, Chien Tin wrote: > Thanks for pointing out the bug. > > > /* Remap the PCI registers in adapter BAR0 to kernel VA space */ > >-mmio_regs = ioremap_nocache(pci_resource_start(pcidev, BAR_0), > >sizeof(mmio_regs)); > >+mmio_regs = ioremap_nocache(pci_resourc

[PATCH 3/5] drivers/infiniband: correct size computation

2009-12-06 Thread Julia Lawall
From: Julia Lawall The size argument to ioremap_nocache should be the size of desired information, not the pointer to it. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @expression@ expression *x; @@ x = <+... -sizeof(x) +sizeof(*x) ...+>//

[PATCH 4/5] drivers/infiniband: remove duplicate structure field initialization

2009-09-19 Thread Julia Lawall
From: Julia Lawall The definition of nes_netdev_ops has initializations of a local function and eth_mac_addr for its ndo_set_mac_address field. This change uses only the local function. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ identifier I