Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1466932
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 6/7] aacraid: Improve determination of a few sizes |
| Date | 2016-08-21 09:30 +0200 |
| Message-ID | <s8vmF-5Nj-11@gated-at.bofh.it> (permalink) |
| References | <qEuGl-43C-5@gated-at.bofh.it> <s8vcZ-5ID-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 08:04:48 +0200
Replace the specification of data structures by references for variables
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/scsi/aacraid/commctrl.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index cda03f0..d2029db 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -177,7 +177,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg)
struct aac_fib_context * fibctx;
int status;
- fibctx = kmalloc(sizeof(struct aac_fib_context), GFP_KERNEL);
+ fibctx = kmalloc(sizeof(*fibctx), GFP_KERNEL);
if (fibctx == NULL) {
status = -ENOMEM;
} else {
@@ -186,7 +186,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg)
struct aac_fib_context * context;
fibctx->type = FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT;
- fibctx->size = sizeof(struct aac_fib_context);
+ fibctx->size = sizeof(*fibctx);
/*
* Yes yes, I know this could be an index, but we have a
* better guarantee of uniqueness for the locked loop below.
@@ -251,7 +251,7 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg)
struct list_head * entry;
unsigned long flags;
- if (copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl)))
+ if (copy_from_user(&f, arg, sizeof(f)))
return -EFAULT;
/*
* Verify that the HANDLE passed in was a valid AdapterFibContext
@@ -509,7 +509,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
srbcmd = (struct aac_srb*) fib_data(srbfib);
memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */
- if (copy_from_user(&fibsize, &user_srb->count, sizeof(u32))) {
+ if (copy_from_user(&fibsize, &user_srb->count, sizeof(fibsize))) {
dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n"));
rcode = -EFAULT;
goto free_sg_list;
--
2.9.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/7] aacraid: Fine-tuning for a few functions SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 09:20 +0200 [PATCH 5/7] aacraid: Add spaces after control flow keywords SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 09:30 +0200 [PATCH 4/7] aacraid: Delete unnecessary braces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 09:30 +0200 [PATCH 2/7] aacraid: One function call less in aac_send_raw_srb() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 09:30 +0200 [PATCH 3/7] aacraid: Delete unnecessary initialisations in aac_send_raw_srb() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 09:30 +0200 [PATCH 6/7] aacraid: Improve determination of a few sizes SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 09:30 +0200 [PATCH 7/7] aacraid: Apply another recommendation from "checkpatch.pl" SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 09:40 +0200
csiph-web