lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <200708042314.24289.m.kozlowski@tuxland.pl>
Date:	Sat, 4 Aug 2007 23:14:22 +0200
From:	Mariusz Kozlowski <m.kozlowski@...land.pl>
To:	Jaroslav Kysela <perex@...e.cz>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] emu10k1: remove redundant memset

Hello,

	This patch removes memset() from snd_emu10k1_fx8010_info() which apparently
isn't needed there. Upatched code uses:

memset(info, 0, sizeof(info));

where 'info' is a pointer and therefore only first 4 bytes of 'info' gets cleared on a 32bit
machine. Anyway looking at the code zeoring this memory region isn't needed at all because
the snd_emu10k1_fx8010_info() function initializes all the 'info' fields on its own.
So that's why this code works at all in its original form.

This patch removes this redundant code. Also snd_emu10k1_fx8010_info() can't fail so lets save
some bytes and change its return type to void.

Signed-off-by: Mariusz Kozlowski <m.kozlowski@...land.pl>

 sound/pci/emu10k1/emufx.c | 101344 -> 101249 (-95 bytes)
 sound/pci/emu10k1/emufx.o | 202652 -> 202552 (-100 bytes)

 sound/pci/emu10k1/emufx.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

--- linux-2.6.23-rc1-mm2-a/sound/pci/emu10k1/emufx.c	2007-08-01 08:43:44.000000000 +0200
+++ linux-2.6.23-rc1-mm2-b/sound/pci/emu10k1/emufx.c	2007-08-04 22:42:20.000000000 +0200
@@ -2440,14 +2440,13 @@ static void copy_string(char *dst, char
 		strcpy(dst, src);
 }

-static int snd_emu10k1_fx8010_info(struct snd_emu10k1 *emu,
+static void snd_emu10k1_fx8010_info(struct snd_emu10k1 *emu,
 				   struct snd_emu10k1_fx8010_info *info)
 {
 	char **fxbus, **extin, **extout;
 	unsigned short fxbus_mask, extin_mask, extout_mask;
 	int res;

-	memset(info, 0, sizeof(info));
 	info->internal_tram_size = emu->fx8010.itram_size;
 	info->external_tram_size = emu->fx8010.etram_pages.bytes / 2;
 	fxbus = fxbuses;
@@ -2464,7 +2463,6 @@ static int snd_emu10k1_fx8010_info(struc
 	for (res = 16; res < 32; res++, extout++)
 		copy_string(info->extout_names[res], extout_mask & (1 << res) ? *extout : NULL, "Unused", res);
 	info->gpr_controls = emu->fx8010.gpr_count;
-	return 0;
 }

 static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg)
@@ -2485,10 +2483,7 @@ static int snd_emu10k1_fx8010_ioctl(stru
 		info = kmalloc(sizeof(*info), GFP_KERNEL);
 		if (!info)
 			return -ENOMEM;
-		if ((res = snd_emu10k1_fx8010_info(emu, info)) < 0) {
-			kfree(info);
-			return res;
-		}
+		snd_emu10k1_fx8010_info(emu, info);
 		if (copy_to_user(argp, info, sizeof(*info))) {
 			kfree(info);
 			return -EFAULT;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ