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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240805155206.463035-1-abhishektamboli9@gmail.com>
Date: Mon,  5 Aug 2024 21:22:06 +0530
From: Abhishek Tamboli <abhishektamboli9@...il.com>
To: perex@...ex.cz,
	tiwai@...e.com
Cc: oswald.buddenhagen@....de,
	skhan@...uxfoundation.org,
	rbmarliere@...il.com,
	linux-kernel-mentees@...ts.linuxfoundation.org,
	linux-sound@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] ALSA: emu10k1: Fix coding style issues and warnings

Fix coding style errors and warnings in sound/pci/emu10k1/memory.c
reported by checkpatch.pl. Changes includes:

- Add spaces after commas in macro definitions.
- Insert blank lines after variable declarations.
- Consistent spacing around operators.
- Remove trailing whitespace.
- Move EXPORT_SYMBOL declarations to immediately follow their
  respective functions.
- Correct spacing in conditional statements and type casts.

Fix the following errors and warnings:

ERROR: space required after that ',' (ctx:VxV)
+#define __set_ptb_entry(emu,page,addr) \

ERROR: space required after that ',' (ctx:VxV)
+#define __set_ptb_entry(emu,page,addr) \

ERROR: space required after that ',' (ctx:VxV)
+#define set_ptb_entry(emu,page,addr)	__set_ptb_entry(emu,page,addr)

ERROR: space required after that ',' (ctx:VxV)
+#define set_ptb_entry(emu,page,addr)	__set_ptb_entry(emu,page,addr)

ERROR: space required after that ',' (ctx:VxV)
+#define set_ptb_entry(emu,page,addr)	__set_ptb_entry(emu,page,addr)

ERROR: space required after that ',' (ctx:VxV)
+#define set_ptb_entry(emu,page,addr)	__set_ptb_entry(emu,page,addr)

ERROR: space required after that ',' (ctx:VxV)
+#define set_silent_ptb(emu,page)
	__set_ptb_entry(emu,page,emu->silent_page.addr)

ERROR: space required after that ',' (ctx:VxV)
+#define set_silent_ptb(emu,page)
	__set_ptb_entry(emu,page,emu->silent_page.addr)

ERROR: space required after that ',' (ctx:VxV)
+#define set_silent_ptb(emu,page)
	__set_ptb_entry(emu,page,emu->silent_page.addr)

WARNING: Missing a blank line after declarations
+	int i;
+	page *= UNIT_PAGES;

WARNING: Missing a blank line after declarations
+	int i;
+	page *= UNIT_PAGES;

ERROR: space required after that ',' (ctx:VxV)
+#define get_emu10k1_memblk(l,member)
	list_entry(l, struct snd_emu10k1_memblk, member)

WARNING: space prohibited between function name and open parenthesis '('
+	list_for_each (pos, &emu->mapped_link_head) {

WARNING: Missing a blank line after declarations
+	struct snd_emu10k1_memblk *blk =
		get_emu10k1_memblk(pos, mapped_link);
+	if (blk->mapped_page < 0)

ERROR: else should follow close brace '}'
+		}
+		else if (size > max_size) {

ERROR: need consistent spacing around '-' (ctx:WxV)
+	psize = get_aligned_page(size + PAGE_SIZE -1);
 	                                          ^

WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
+EXPORT_SYMBOL(snd_emu10k1_memblk_map);

WARNING: Missing a blank line after declarations
+		dma_addr_t addr;
+		if (ofs >= runtime->dma_bytes)

ERROR: space prohibited after that '!' (ctx:BxW)
+		if (! is_valid_page(emu, addr)) {
 		    ^

ERROR: trailing whitespace
+^Istruct snd_util_memhdr *hdr = hw->memhdr; $

WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
+EXPORT_SYMBOL(snd_emu10k1_synth_alloc);

ERROR: trailing whitespace
+^Istruct snd_util_memhdr *hdr = emu->memhdr; $

WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
+EXPORT_SYMBOL(snd_emu10k1_synth_free);

WARNING: Missing a blank line after declarations
+	int first_page, last_page;
+	first_page = blk->first_page;

WARNING: Missing a blank line after declarations
+	char *ptr;
+	if (snd_BUG_ON(page < 0 || page >= emu->max_cache_pages))

ERROR: space prohibited after that '!' (ctx:BxW)
+	if (! ptr) {
 	    ^

ERROR: "(foo*)" should be "(foo *)"
+	return (void*)ptr;

WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
+EXPORT_SYMBOL(snd_emu10k1_synth_memset);

WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
+EXPORT_SYMBOL(snd_emu10k1_synth_copy_from_user);

Signed-off-by: Abhishek Tamboli <abhishektamboli9@...il.com>
---
 sound/pci/emu10k1/memory.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c
index d29711777161..124497c14fb0 100644
--- a/sound/pci/emu10k1/memory.c
+++ b/sound/pci/emu10k1/memory.c
@@ -18,7 +18,7 @@
 /* page arguments of these two macros are Emu page (4096 bytes), not like
  * aligned pages in others
  */
-#define __set_ptb_entry(emu,page,addr) \
+#define __set_ptb_entry(emu, page, addr) \
 	(((__le32 *)(emu)->ptb_pages.area)[page] = \
 	 cpu_to_le32(((addr) << (emu->address_mode)) | (page)))
 #define __get_ptb_entry(emu, page) \
@@ -34,14 +34,15 @@

 #if PAGE_SIZE == EMUPAGESIZE && !IS_ENABLED(CONFIG_DYNAMIC_DEBUG)
 /* fill PTB entrie(s) corresponding to page with addr */
-#define set_ptb_entry(emu,page,addr)	__set_ptb_entry(emu,page,addr)
+#define set_ptb_entry(emu, page, addr)	__set_ptb_entry(emu, page, addr)
 /* fill PTB entrie(s) corresponding to page with silence pointer */
-#define set_silent_ptb(emu,page)	__set_ptb_entry(emu,page,emu->silent_page.addr)
+#define set_silent_ptb(emu, page)	__set_ptb_entry(emu, page, emu->silent_page.addr)
 #else
 /* fill PTB entries -- we need to fill UNIT_PAGES entries */
 static inline void set_ptb_entry(struct snd_emu10k1 *emu, int page, dma_addr_t addr)
 {
 	int i;
+
 	page *= UNIT_PAGES;
 	for (i = 0; i < UNIT_PAGES; i++, page++) {
 		__set_ptb_entry(emu, page, addr);
@@ -53,6 +54,7 @@ static inline void set_ptb_entry(struct snd_emu10k1 *emu, int page, dma_addr_t a
 static inline void set_silent_ptb(struct snd_emu10k1 *emu, int page)
 {
 	int i;
+
 	page *= UNIT_PAGES;
 	for (i = 0; i < UNIT_PAGES; i++, page++) {
 		/* do not increment ptr */
@@ -69,7 +71,7 @@ static inline void set_silent_ptb(struct snd_emu10k1 *emu, int page)
 static int synth_alloc_pages(struct snd_emu10k1 *hw, struct snd_emu10k1_memblk *blk);
 static int synth_free_pages(struct snd_emu10k1 *hw, struct snd_emu10k1_memblk *blk);

-#define get_emu10k1_memblk(l,member)	list_entry(l, struct snd_emu10k1_memblk, member)
+#define get_emu10k1_memblk(l, member)	list_entry(l, struct snd_emu10k1_memblk, member)


 /* initialize emu10k1 part */
@@ -100,16 +102,16 @@ static int search_empty_map_area(struct snd_emu10k1 *emu, int npages, struct lis
 	struct list_head *candidate = &emu->mapped_link_head;
 	struct list_head *pos;

-	list_for_each (pos, &emu->mapped_link_head) {
+	list_for_each(pos, &emu->mapped_link_head) {
 		struct snd_emu10k1_memblk *blk = get_emu10k1_memblk(pos, mapped_link);
+
 		if (blk->mapped_page < 0)
 			continue;
 		size = blk->mapped_page - page;
 		if (size == npages) {
 			*nextp = pos;
 			return page;
-		}
-		else if (size > max_size) {
+		} else if (size > max_size) {
 			/* we look for the maximum empty hole */
 			max_size = size;
 			candidate = pos;
@@ -209,7 +211,7 @@ search_empty(struct snd_emu10k1 *emu, int size)
 	struct snd_emu10k1_memblk *blk;
 	int page, psize;

-	psize = get_aligned_page(size + PAGE_SIZE -1);
+	psize = get_aligned_page(size + PAGE_SIZE - 1);
 	page = 0;
 	list_for_each(p, &emu->memhdr->block) {
 		blk = get_emu10k1_memblk(p, mem.list);
@@ -292,7 +294,6 @@ int snd_emu10k1_memblk_map(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *b
 	spin_unlock_irqrestore(&emu->memblk_lock, flags);
 	return err;
 }
-
 EXPORT_SYMBOL(snd_emu10k1_memblk_map);

 /*
@@ -328,11 +329,12 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst
 	for (page = blk->first_page; page <= blk->last_page; page++, idx++) {
 		unsigned long ofs = idx << PAGE_SHIFT;
 		dma_addr_t addr;
+
 		if (ofs >= runtime->dma_bytes)
 			addr = emu->silent_page.addr;
 		else
 			addr = snd_pcm_sgbuf_get_addr(substream, ofs);
-		if (! is_valid_page(emu, addr)) {
+		if (!is_valid_page(emu, addr)) {
 			dev_err_ratelimited(emu->card->dev,
 				"emu: failure page = %d\n", idx);
 			mutex_unlock(&hdr->block_mutex);
@@ -405,7 +407,7 @@ struct snd_util_memblk *
 snd_emu10k1_synth_alloc(struct snd_emu10k1 *hw, unsigned int size)
 {
 	struct snd_emu10k1_memblk *blk;
-	struct snd_util_memhdr *hdr = hw->memhdr;
+	struct snd_util_memhdr *hdr = hw->memhdr;

 	mutex_lock(&hdr->block_mutex);
 	blk = (struct snd_emu10k1_memblk *)__snd_util_mem_alloc(hdr, size);
@@ -422,7 +424,6 @@ snd_emu10k1_synth_alloc(struct snd_emu10k1 *hw, unsigned int size)
 	mutex_unlock(&hdr->block_mutex);
 	return (struct snd_util_memblk *)blk;
 }
-
 EXPORT_SYMBOL(snd_emu10k1_synth_alloc);

 /*
@@ -431,7 +432,7 @@ EXPORT_SYMBOL(snd_emu10k1_synth_alloc);
 int
 snd_emu10k1_synth_free(struct snd_emu10k1 *emu, struct snd_util_memblk *memblk)
 {
-	struct snd_util_memhdr *hdr = emu->memhdr;
+	struct snd_util_memhdr *hdr = emu->memhdr;
 	struct snd_emu10k1_memblk *blk = (struct snd_emu10k1_memblk *)memblk;
 	unsigned long flags;

@@ -445,7 +446,6 @@ snd_emu10k1_synth_free(struct snd_emu10k1 *emu, struct snd_util_memblk *memblk)
 	mutex_unlock(&hdr->block_mutex);
 	return 0;
 }
-
 EXPORT_SYMBOL(snd_emu10k1_synth_free);

 /* check new allocation range */
@@ -456,6 +456,7 @@ static void get_single_page_range(struct snd_util_memhdr *hdr,
 	struct list_head *p;
 	struct snd_emu10k1_memblk *q;
 	int first_page, last_page;
+
 	first_page = blk->first_page;
 	p = blk->mem.list.prev;
 	if (p != &hdr->block) {
@@ -552,16 +553,17 @@ static int synth_free_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *
 static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset)
 {
 	char *ptr;
+
 	if (snd_BUG_ON(page < 0 || page >= emu->max_cache_pages))
 		return NULL;
 	ptr = emu->page_ptr_table[page];
-	if (! ptr) {
+	if (!ptr) {
 		dev_err(emu->card->dev,
 			"access to NULL ptr: page = %d\n", page);
 		return NULL;
 	}
 	ptr += offset & (PAGE_SIZE - 1);
-	return (void*)ptr;
+	return (void *)ptr;
 }

 /*
@@ -594,7 +596,6 @@ int snd_emu10k1_synth_memset(struct snd_emu10k1 *emu, struct snd_util_memblk *bl
 	} while (offset < end_offset);
 	return 0;
 }
-
 EXPORT_SYMBOL(snd_emu10k1_synth_memset);

 // Note that the value is assumed to be suitably repetitive.
@@ -659,5 +660,4 @@ int snd_emu10k1_synth_copy_from_user(struct snd_emu10k1 *emu, struct snd_util_me
 	} while (offset < end_offset);
 	return 0;
 }
-
 EXPORT_SYMBOL(snd_emu10k1_synth_copy_from_user);
--
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ