From: Elizabeth Ferdman <gnudevliz@gmail.com>
To: outreachy-kernel@googlegroups.com
Cc: julia.lawall@lip6.fr
Subject: Coccinelle Small Task 1
Date: Mon, 17 Oct 2016 00:05:13 -0700 [thread overview]
Message-ID: <20161017070509.GA21688@localhost> (raw)
[-- 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);
reply other threads:[~2016-10-17 7:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161017070509.GA21688@localhost \
--to=gnudevliz@gmail.com \
--cc=julia.lawall@lip6.fr \
--cc=outreachy-kernel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.