All of lore.kernel.org
 help / color / mirror / Atom feed
* Coccinelle Small Task 1
@ 2016-10-17  7:05 Elizabeth Ferdman
  0 siblings, 0 replies; only message in thread
From: Elizabeth Ferdman @ 2016-10-17  7:05 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: julia.lawall

[-- Attachment #1: Type: text/plain, Size: 167 bytes --]

Hey Julia,

I'm attaching Small Task 1. I found 9 cases where I thought
constification was not possible and one where it was and I sent in a
patch for that one. 

Liz

[-- Attachment #2: cannotconst --]
[-- Type: text/plain, Size: 2763 bytes --]

Constification is not possible in these cases because they break one of these rules: 

1. Never reassigned.
2. Address never taken
3. Not passed to a top-level macro call
4. No pointer or array-typed field passed to a function or stored in a
variable.

1. drivers/staging/vme/devices/vme_user.c contains this struct:

static struct vme_driver vme_user_driver = {
         .name = driver_name,
         .match = vme_user_match,
         .probe = vme_user_probe,
         .remove = vme_user_remove,
}

&vme_user_driver is then passed to this function where its members are being modified:

int vme_register_driver(struct vme_driver *drv, unsigned int ndevs)
{

         drv->driver.name = drv->name;
         drv->driver.bus = &vme_bus_type;

2. Similar pattern occurs in drivers/staging/rtl8192u/r8192U_core.c 

static struct usb_driver rtl8192_usb_driver

is passed to usb_register and then usb_register_driver which modifies its members.

The pattern seems to be when a struct is passed to a function with "register" in the name it gets modified?

3. drivers/staging/sm750fb/sm750.c contains this struct:

static struct fb_ops lynxfb_ops = {
        .owner = THIS_MODULE,
        .fb_check_var =  lynxfb_ops_check_var,
        .fb_set_par = lynxfb_ops_set_par,
        .fb_setcolreg = lynxfb_ops_setcolreg,
        .fb_blank = lynxfb_ops_blank,
        .fb_fillrect = cfb_fillrect,
        .fb_imageblit = cfb_imageblit,
        .fb_copyarea = cfb_copyarea,
        /* cursor */
        .fb_cursor = lynxfb_ops_cursor,
};

it gets assigned a new member in the same file:

        lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;

4. drivers/staging/rtl8712/usb_intf.c contains
static struct drv_priv drvpriv = {...}

The init function modifies this struct: 
static int __init r8712u_drv_entry(void)
{
        drvpriv.drv_registered = true;
5. In drivers/staging/wilc1000/wilc_sdio.c
 static struct sdio_driver wilc1000_sdio_driver is passed to module_driverfunction which is a macro call.

6. In drivers/staging/octeon-usb/octeon-hcd.c,
There is a 
static struct platform_driver octeon_usb_driver

Its address is passed to a platform_driver_register function 

7. In drivers/staging/comedi/drivers/rtd520.c,

The address of static struct comedi_driver rtd520_driver is passed to comedi_pci_auto_config

8. In drivers/staging/android/ion/ion_carveout_heap.c,

static struct ion_heap_ops carveout_heap_ops 

There is an assignment which looks like this: 

carveout_heap->heap.ops = &carveout_heap_ops;

The address shouldn't be taken 

9. In  drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c:

static struct ieee80211_crypto_ops ieee80211_crypt_null

Its address is passed to a register function 
ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-17  7:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-17  7:05 Coccinelle Small Task 1 Elizabeth Ferdman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.