All of lore.kernel.org
 help / color / mirror / Atom feed
* Clarification on last_comp_len logic in zram_write_page
@ 2024-12-13  7:19 Dheeraj Reddy Jonnalagadda
  2024-12-13  8:00 ` Sergey Senozhatsky
  0 siblings, 1 reply; 2+ messages in thread
From: Dheeraj Reddy Jonnalagadda @ 2024-12-13  7:19 UTC (permalink / raw)
  To: minchan, senozhatsky; +Cc: axboe, linux-kernel, linux-block

Dear Maintainers,

I am writing to seek clarification regarding the use of last_comp_len
variable in zram_write_page function. Specifically, Coverity has flagged 
the issue (CID 1602439) in zram/zram_drv.c

Link to the coverity issue:
https://scan7.scan.coverity.com/#/project-view/52337/11354?selectedIssue=1602439

Currently, last_comp_len is initialized to 0 but never updated within the
function. This renders the conditional block shown below as dead code.

	if (last_comp_len && (last_comp_len != comp_len)) {
    		zs_free(zram->mem_pool, handle);
    		handle = -ENOMEM;
	}

From the context, it appears that this variable might be intended to track the
compression length from a previous iteration for comparison purposes.

I would like to confirm the intended behavior here:

	1. Should last_comp_len be updated to comp_len after every compression
	 iteration to enable this comparison?

	2. Is this logic necessary for scenarios where compression lengths
	differ between iterations, or can this block be removed altogether?

To address this, I propose a fix where last_comp_len is updated after the
conditional block as shown below, ensuring it reflects the last compression
length:
	if (last_comp_len && (last_comp_len != comp_len)) {
    		zs_free(zram->mem_pool, handle);
    		andle = -ENOMEM;
	}
	last_comp_len = comp_len;

Could you please clarify whether this approach aligns with the intended
functionality of the code?

Thank you for your time and assistance.

-Dheeraj

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-13  8:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-13  7:19 Clarification on last_comp_len logic in zram_write_page Dheeraj Reddy Jonnalagadda
2024-12-13  8:00 ` Sergey Senozhatsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.