tiny patch: avoid an unnecessary test
Not a big deal (barely worth mentioning), but it might save someone else a little time wondering "why".
2007-03-11 Jim Meyering <[email protected]>
Remove unnecessary test.
* dmeventd/dmeventd.c (_alloc_dso_data): Don't test known-non-NULL memset return value.
2007-03-11 Jim Meyering <[email protected]>
Index: dmeventd/dmeventd.c
===================================================================
RCS file: /cvs/dm/device-mapper/dmeventd/dmeventd.c,v retrieving revision 1.46
dmeventd.c +2 -2
@@ -258,8 +258,8 @@ static struct dso_data *_alloc_dso_data(if (!ret)return NULL ; -if (!memset (ret,0 ,sizeof (*ret)) || - !(ret->dso_name =dm_strdup (data->dso_name))) { +memset (ret,0 ,sizeof (*ret)); +if (!(ret->dso_name =dm_strdup (data->dso_name))) {dm_free (ret);return NULL ; }
Actually, there's a chance you'd get a NULL pointer error if you don't have that check if I'm reading the context right. Linux doesn't guarantee malloc will return NULL if memory is unavailable, you only get the error when you attempt to write to memory. So if there is an allocation error, you're only going to see it in the memset.
--
AJ
Quoted 33 lines · Jim Meyering
Not a big deal (barely worth mentioning), but it might save someone else a little time wondering "why".
2007-03-11 Jim Meyering <[email protected]>
Remove unnecessary test.
*dmeventd/dmeventd.c(_alloc_dso_data): Don't test known-non-NULL memset return value.2007-03-11 Jim Meyering <[email protected]>
Index:dmeventd/dmeventd.c
===================================================================
RCS file: /cvs/dm/device-mapper/dmeventd/dmeventd.c,v retrieving revision 1.46
diff -u -p -r1.46dmeventd.cdmeventd.c +2
-3@@ -258,8 +258,8 @@ static struct dso_data *_alloc_dso_data(if (!ret)return NULL ; -if (!memset (ret,0 ,sizeof (*ret)) || - !(ret->dso_name =dm_strdup (data->dso_name))) { +memset (ret,0 ,sizeof (*ret)); +if (!(ret->dso_name =dm_strdup (data->dso_name))) {dm_free (ret);return NULL ; } --dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
Never mind - looking at the optimistic memory allocation stuff again, you'll just get OOMed.
Quoted 50 lines · AJ Lewis
Actually, there's a chance you'd get a NULL pointer error if you don't have that check if I'm reading the context right. Linux doesn't guarantee malloc will return NULL if memory is unavailable, you only get the error when you attempt to write to memory. So if there is an allocation error, you're only going to see it in the memset.
--
AJQuoted 30 lines · Jim Meyering
Not a big deal (barely worth mentioning), but it might save someone else a little time wondering "why".
2007-03-11 Jim Meyering <[email protected]>
Remove unnecessary test.
*dmeventd/dmeventd.c(_alloc_dso_data): Don't test known-non-NULL memset return value.2007-03-11 Jim Meyering <[email protected]>
Index:dmeventd/dmeventd.c
===================================================================
RCS file: /cvs/dm/device-mapper/dmeventd/dmeventd.c,v retrieving revision 1.46
diff -u -p -r1.46dmeventd.cdmeventd.c +2
-3@@ -258,8 +258,8 @@ static struct dso_data *_alloc_dso_data(if (!ret)return NULL ; -if (!memset (ret,0 ,sizeof (*ret)) || - !(ret->dso_name =dm_strdup (data->dso_name))) { +memset (ret,0 ,sizeof (*ret)); +if (!(ret->dso_name =dm_strdup (data->dso_name))) {dm_free (ret);return NULL ; } --Quoted 3 lines
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel