Convert alloc+sprintf pairs into asprintf() & XNFasprintf() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
This commit is contained in:
@@ -63,10 +63,8 @@ device_removed(LibHalContext *ctx, const char *udi)
|
||||
{
|
||||
char *value;
|
||||
|
||||
value = malloc(strlen(udi) + 5); /* "hal:" + NULL */
|
||||
if (!value)
|
||||
if (asprintf (&value, "hal:%s", udi) == -1)
|
||||
return;
|
||||
sprintf(value, "hal:%s", udi);
|
||||
|
||||
remove_devices("hal", value);
|
||||
|
||||
@@ -228,12 +226,11 @@ device_added(LibHalContext *hal_ctx, const char *udi)
|
||||
add_option(&options, "driver", driver);
|
||||
add_option(&options, "name", name);
|
||||
|
||||
config_info = malloc(strlen(udi) + 5); /* "hal:" and NULL */
|
||||
if (!config_info) {
|
||||
if (asprintf (&config_info, "hal:%s", udi) == -1) {
|
||||
config_info = NULL;
|
||||
LogMessage(X_ERROR, "config/hal: couldn't allocate name\n");
|
||||
goto unwind;
|
||||
}
|
||||
sprintf(config_info, "hal:%s", udi);
|
||||
|
||||
/* Check for duplicate devices */
|
||||
if (device_is_duplicate(config_info))
|
||||
|
||||
Reference in New Issue
Block a user