From 6d65bfcf809d9b9be08027472ab1884c709d65c0 Mon Sep 17 00:00:00 2001 From: Patrick Marlier Date: Tue, 4 Dec 2012 09:06:06 +0100 Subject: [PATCH] lib: g_malloc never fails Or rather, it never returns errors and aborts instead if memory cannot be allocated, so remove code that handled failures. https://bugs.freedesktop.org/show_bug.cgi?id=57869 --- libfprint/drivers/aes1660.c | 9 --------- libfprint/drivers/aes2550.c | 4 ---- libfprint/drivers/aes2660.c | 9 --------- libfprint/drivers/aesx660.c | 4 ---- 4 files changed, 26 deletions(-) diff --git a/libfprint/drivers/aes1660.c b/libfprint/drivers/aes1660.c index e647ea5..250ca52 100644 --- a/libfprint/drivers/aes1660.c +++ b/libfprint/drivers/aes1660.c @@ -48,16 +48,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) } dev->priv = aesdev = g_malloc0(sizeof(struct aesX660_dev)); - if (!aesdev) - return -ENOMEM; - aesdev->buffer = g_malloc0(AES1660_FRAME_SIZE + AESX660_HEADER_SIZE); - if (!aesdev->buffer) { - g_free(aesdev); - dev->priv = NULL; - return -ENOMEM; - } - aesdev->h_scale_factor = SCALE_FACTOR; aesdev->init_seqs[0] = aes1660_init_1; aesdev->init_seqs_len[0] = array_n_elements(aes1660_init_1); diff --git a/libfprint/drivers/aes2550.c b/libfprint/drivers/aes2550.c index 96ce590..dcfbc82 100644 --- a/libfprint/drivers/aes2550.c +++ b/libfprint/drivers/aes2550.c @@ -215,10 +215,6 @@ static int process_strip_data(struct fpi_ssm *ssm, unsigned char *data) fp_dbg("Bogus frame len: %.4x\n", len); } stripdata = g_malloc(FRAME_WIDTH * FRAME_HEIGHT / 2); /* 4 bits per pixel */ - if (!stripdata) { - fpi_ssm_mark_aborted(ssm, -ENOMEM); - return -ENOMEM; - } memcpy(stripdata, data + 33, FRAME_WIDTH * FRAME_HEIGHT / 2); aesdev->strips = g_slist_prepend(aesdev->strips, stripdata); aesdev->strips_len++; diff --git a/libfprint/drivers/aes2660.c b/libfprint/drivers/aes2660.c index bc1dd00..4be7475 100644 --- a/libfprint/drivers/aes2660.c +++ b/libfprint/drivers/aes2660.c @@ -47,16 +47,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) } dev->priv = aesdev = g_malloc0(sizeof(struct aesX660_dev)); - if (!aesdev) - return -ENOMEM; - aesdev->buffer = g_malloc0(AES2660_FRAME_SIZE + AESX660_HEADER_SIZE); - if (!aesdev->buffer) { - g_free(aesdev); - dev->priv = NULL; - return -ENOMEM; - } - /* No scaling for AES2660 */ aesdev->h_scale_factor = 1; aesdev->init_seqs[0] = aes2660_init_1; diff --git a/libfprint/drivers/aesx660.c b/libfprint/drivers/aesx660.c index ff4f50c..d030d0e 100644 --- a/libfprint/drivers/aesx660.c +++ b/libfprint/drivers/aesx660.c @@ -278,10 +278,6 @@ static int process_stripe_data(struct fpi_ssm *ssm, unsigned char *data) struct aesX660_dev *aesdev = dev->priv; stripdata = g_malloc(aesdev->frame_width * FRAME_HEIGHT / 2); /* 4 bits per pixel */ - if (!stripdata) { - fpi_ssm_mark_aborted(ssm, -ENOMEM); - return 1; - } fp_dbg("Processing frame %.2x %.2x", data[AESX660_IMAGE_OK_OFFSET], data[AESX660_LAST_FRAME_OFFSET]);