* [PATCH 0/3] fs-udf: Adjustments for some function implementations
@ 2017-08-15 15:35 SF Markus Elfring
2017-08-15 15:36 ` [PATCH 1/3] fs-udf: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-08-15 15:35 UTC (permalink / raw)
To: Jan Kara, kernel-janitors; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 15 Aug 2017 17:10:12 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in two functions
Improve six size determinations
Adjust two checks for null pointers
fs/udf/inode.c | 13 ++++---------
fs/udf/namei.c | 2 +-
fs/udf/super.c | 12 +++++-------
3 files changed, 10 insertions(+), 17 deletions(-)
--
2.14.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] fs-udf: Delete an error message for a failed memory allocation in two functions
2017-08-15 15:35 [PATCH 0/3] fs-udf: Adjustments for some function implementations SF Markus Elfring
@ 2017-08-15 15:36 ` SF Markus Elfring
2017-08-15 15:37 ` [PATCH 2/3] fs-udf: Improve six size determinations SF Markus Elfring
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-08-15 15:36 UTC (permalink / raw)
To: Jan Kara, kernel-janitors; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 15 Aug 2017 16:14:19 +0200
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/udf/inode.c | 7 +------
fs/udf/super.c | 2 --
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 18fdb9d90812..7b50afc6e0c3 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1572,13 +1572,8 @@ static int udf_alloc_i_data(struct inode *inode, size_t size)
{
struct udf_inode_info *iinfo = UDF_I(inode);
iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL);
-
- if (!iinfo->i_ext.i_data) {
- udf_err(inode->i_sb, "(ino %ld) no free memory\n",
- inode->i_ino);
+ if (!iinfo->i_ext.i_data)
return -ENOMEM;
- }
-
return 0;
}
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 462ac2e9258c..ca4b4274b524 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -271,6 +271,4 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
if (!sbi->s_partmaps) {
- udf_err(sb, "Unable to allocate space for %d partition maps\n",
- count);
sbi->s_partitions = 0;
return -ENOMEM;
}
--
2.14.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] fs-udf: Improve six size determinations
2017-08-15 15:35 [PATCH 0/3] fs-udf: Adjustments for some function implementations SF Markus Elfring
2017-08-15 15:36 ` [PATCH 1/3] fs-udf: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
@ 2017-08-15 15:37 ` SF Markus Elfring
2017-08-15 15:38 ` [PATCH 3/3] fs-udf: Adjust two checks for null pointers SF Markus Elfring
2017-08-16 14:43 ` [PATCH 0/3] fs-udf: Adjustments for some function implementations Jan Kara
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-08-15 15:37 UTC (permalink / raw)
To: Jan Kara, kernel-janitors; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 15 Aug 2017 16:45:44 +0200
Replace the specification of data structures by variable references
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>
---
fs/udf/inode.c | 6 +++---
fs/udf/namei.c | 2 +-
fs/udf/super.c | 5 ++---
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 7b50afc6e0c3..8dacf4f57414 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -114,7 +114,7 @@ static void udf_update_extent_cache(struct inode *inode, loff_t estart,
__udf_clear_extent_cache(inode);
if (pos->bh)
get_bh(pos->bh);
- memcpy(&iinfo->cached_extent.epos, pos, sizeof(struct extent_position));
+ memcpy(&iinfo->cached_extent.epos, pos, sizeof(*pos));
iinfo->cached_extent.lstart = estart;
switch (iinfo->i_alloc_type) {
case ICBTAG_FLAG_AD_SHORT:
@@ -1698,7 +1698,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
dsea->impUseLength = cpu_to_le32(sizeof(struct regid));
}
eid = (struct regid *)dsea->impUse;
- memset(eid, 0, sizeof(struct regid));
+ memset(eid, 0, sizeof(*eid));
strcpy(eid->ident, UDF_ID_DEVELOPER);
eid->identSuffix[0] = UDF_OS_CLASS_UNIX;
eid->identSuffix[1] = UDF_OS_ID_LINUX;
@@ -1749,7 +1749,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
udf_time_to_disk_stamp(&efe->createTime, iinfo->i_crtime);
udf_time_to_disk_stamp(&efe->attrTime, inode->i_ctime);
- memset(&(efe->impIdent), 0, sizeof(struct regid));
+ memset(&(efe->impIdent), 0, sizeof(efe->impIdent));
strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER);
efe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
efe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 385ee89d5824..885198dfd9f8 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -1184,7 +1184,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
*/
ncfi.fileVersionNum = ocfi.fileVersionNum;
ncfi.fileCharacteristics = ocfi.fileCharacteristics;
- memcpy(&(ncfi.icb), &(ocfi.icb), sizeof(struct long_ad));
+ memcpy(&(ncfi.icb), &(ocfi.icb), sizeof(ocfi.icb));
udf_write_fi(new_dir, &ncfi, nfi, &nfibh, NULL, NULL);
/* The old fid may have moved - find it again */
diff --git a/fs/udf/super.c b/fs/udf/super.c
index ca4b4274b524..0dc7c2d9f0fa 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -266,6 +266,5 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
{
struct udf_sb_info *sbi = UDF_SB(sb);
- sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map),
- GFP_KERNEL);
+ sbi->s_partmaps = kcalloc(count, sizeof(*sbi->s_partmaps), GFP_KERNEL);
if (!sbi->s_partmaps) {
@@ -2097,7 +2096,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
uopt.fmode = UDF_INVALID_MODE;
uopt.dmode = UDF_INVALID_MODE;
- sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL);
+ sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
--
2.14.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] fs-udf: Adjust two checks for null pointers
2017-08-15 15:35 [PATCH 0/3] fs-udf: Adjustments for some function implementations SF Markus Elfring
2017-08-15 15:36 ` [PATCH 1/3] fs-udf: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2017-08-15 15:37 ` [PATCH 2/3] fs-udf: Improve six size determinations SF Markus Elfring
@ 2017-08-15 15:38 ` SF Markus Elfring
2017-08-16 14:43 ` [PATCH 0/3] fs-udf: Adjustments for some function implementations Jan Kara
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-08-15 15:38 UTC (permalink / raw)
To: Jan Kara, kernel-janitors; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 15 Aug 2017 17:03:06 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written !…
Thus fix affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/udf/super.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 0dc7c2d9f0fa..93c59630512b 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -321,7 +321,8 @@ static void udf_sb_free_partitions(struct super_block *sb)
{
struct udf_sb_info *sbi = UDF_SB(sb);
int i;
- if (sbi->s_partmaps == NULL)
+
+ if (!sbi->s_partmaps)
return;
for (i = 0; i < sbi->s_partitions; i++)
udf_free_partition(&sbi->s_partmaps[i]);
@@ -1068,7 +1069,7 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
else
bitmap = vzalloc(size); /* TODO: get rid of vzalloc */
- if (bitmap == NULL)
+ if (!bitmap)
return NULL;
bitmap->s_nr_groups = nr_groups;
--
2.14.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] fs-udf: Adjustments for some function implementations
2017-08-15 15:35 [PATCH 0/3] fs-udf: Adjustments for some function implementations SF Markus Elfring
` (2 preceding siblings ...)
2017-08-15 15:38 ` [PATCH 3/3] fs-udf: Adjust two checks for null pointers SF Markus Elfring
@ 2017-08-16 14:43 ` Jan Kara
3 siblings, 0 replies; 5+ messages in thread
From: Jan Kara @ 2017-08-16 14:43 UTC (permalink / raw)
To: SF Markus Elfring; +Cc: Jan Kara, kernel-janitors, LKML
On Tue 15-08-17 17:35:42, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 15 Aug 2017 17:10:12 +0200
>
> A few update suggestions were taken into account
> from static source code analysis.
OK, makes sense. I've applied all three patches. Thanks!
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-16 14:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-15 15:35 [PATCH 0/3] fs-udf: Adjustments for some function implementations SF Markus Elfring
2017-08-15 15:36 ` [PATCH 1/3] fs-udf: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2017-08-15 15:37 ` [PATCH 2/3] fs-udf: Improve six size determinations SF Markus Elfring
2017-08-15 15:38 ` [PATCH 3/3] fs-udf: Adjust two checks for null pointers SF Markus Elfring
2017-08-16 14:43 ` [PATCH 0/3] fs-udf: Adjustments for some function implementations Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).