Re: [PATCH v2 2/3] mm/memory_hotplug: Drop mem_blk check from unregister_mem_sect_under_nodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 14.08.2018 11:36, Oscar Salvador wrote:
> On Tue, Aug 14, 2018 at 11:30:51AM +0200, David Hildenbrand wrote:
> 
>>
>> While it is correct in current code, I wonder if this sanity check
>> should stay. I would completely agree if it would be a static function.
> 
> Hi David,
> 
> Well, unregister_mem_sect_under_nodes() __only__ gets called from remove_memory_section().
> But remove_memory_section() only calls unregister_mem_sect_under_nodes() IFF mem_blk
> is not NULL:
> 
> static int remove_memory_section
> {
> 	...
> 	mem = find_memory_block(section);
> 	if (!mem)
> 		goto out_unlock;
> 
> 	unregister_mem_sect_under_nodes(mem, __section_nr(section));
> 	...
> }

Yes I know, as I said, if it would be local to a file I would not care.
Making this functions never return an error is nice, though (and as you
noted, the return value is never checked).

I am a friend of stating which conditions a function expects to hold if
a function can be called from other parts of the system. Usually I
prefer to use BUG_ONs for that (whoever decides to call it can directly
see what he as to check before calling) or comments. But comments tend
to become obsolete.

> 
> So, to me keeping the check is redundant, as we already check for it before calling in.
> 
> Thanks
> 


-- 

Thanks,

David / dhildenb




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux