summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-03-11 11:28:15 +0100
committerHans de Goede <hdegoede@redhat.com>2014-03-12 08:50:05 +0100
commit92ff79f1a804d63d2f2bb59dfbf3a2869627609a (patch)
tree8b56ea3b223e4bfcc20c4f611c73a18d8d73aac4 /config
parente7b84ca46944895971a8f048c7e34869b7de01c0 (diff)
config_odev*: Use XNF alloc functions
config_odev* functions are called in code-paths were we already use XNF* functions in other places, so which are not oom safe already. Besides that oom is something which should simply never happen, so aborting when it does is as good a response as any other. While switching to XNF functions also fixup an unchecked strdup case. Note the function prototypes are kept unchanged, as they are part of the server ABI. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'config')
-rw-r--r--config/config.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/config/config.c b/config/config.c
index 46f2532ec..def7f16ca 100644
--- a/config/config.c
+++ b/config/config.c
@@ -132,10 +132,7 @@ config_odev_allocate_attribute_list(void)
{
struct OdevAttributes *attriblist;
- attriblist = malloc(sizeof(struct OdevAttributes));
- if (!attriblist)
- return NULL;
-
+ attriblist = XNFalloc(sizeof(struct OdevAttributes));
xorg_list_init(&attriblist->list);
return attriblist;
}
@@ -168,10 +165,7 @@ config_odev_find_or_add_attribute(struct OdevAttributes *attribs, int attrib)
if (oa)
return oa;
- oa = calloc(1, sizeof(struct OdevAttribute));
- if (!oa)
- return oa;
-
+ oa = XNFcalloc(sizeof(struct OdevAttribute));
oa->attrib_id = attrib;
xorg_list_append(&oa->member, &attribs->list);
@@ -185,11 +179,8 @@ config_odev_add_attribute(struct OdevAttributes *attribs, int attrib,
struct OdevAttribute *oa;
oa = config_odev_find_or_add_attribute(attribs, attrib);
- if (!oa)
- return FALSE;
-
free(oa->attrib_name);
- oa->attrib_name = strdup(attrib_name);
+ oa->attrib_name = XNFstrdup(attrib_name);
oa->attrib_type = ODEV_ATTRIB_STRING;
return TRUE;
}
@@ -201,9 +192,6 @@ config_odev_add_int_attribute(struct OdevAttributes *attribs, int attrib,
struct OdevAttribute *oa;
oa = config_odev_find_or_add_attribute(attribs, attrib);
- if (!oa)
- return FALSE;
-
oa->attrib_value = attrib_value;
oa->attrib_type = ODEV_ATTRIB_INT;
return TRUE;