Skip to contentSkip to conversation

Significance Of sort() In include/linux/sort.h

DISCUSSION Soumyadip Das Mahapatra 3 participants 3 messages Jun 18, 2008

lore
Share & tools
lore
#0 lore raw

Hello everybody,
I dont understand what is the significance of keeping
include/linux/sort.h and lib/sort.c while i think there is none using (#include<linux/sort.h>) it. Can anyone explaint it?

Thanks :-)

#1 lore raw
Quoted 4 lines · Soumyadip Das Mahapatra

Hello everybody,
I dont understand what is the significance of keeping
include/linux/sort.h and lib/sort.c while i think there is none using (#include<linux/sort.h>) it. Can anyone explaint it?

Huh? Am I missing something here?

[/usr/src/linux-2.6] find . -name '*.[ch]' | xargs grep linux/sort ./arch/x86/kernel/setup_64.c:#include <linux/sort.h> ./arch/x86/kernel/mmconf-fam10h_64.c:#include <linux/sort.h> ./arch/x86/kernel/test_nx.c:#include <linux/sort.h> ./arch/sparc/prom/memory.c:#include <linux/sort.h> ./arch/sparc64/mm/init.c:#include <linux/sort.h> ./arch/powerpc/kernel/module_32.c:#include <linux/sort.h> ./arch/powerpc/kernel/module_64.c:#include <linux/sort.h> ./arch/ia64/mm/extable.c:#include <linux/sort.h> ./kernel/cgroup.c:#include <linux/sort.h> ./kernel/cpuset.c:#include <linux/sort.h> ./kernel/lockdep_proc.c:#include <linux/sort.h> ./drivers/net/pppol2tp.c:#include <linux/sort.h> ./drivers/media/video/saa7134/saa7134-video.c:#include <linux/sort.h> ./drivers/media/video/v4l2-int-device.c:#include <linux/sort.h> ./drivers/message/fusion/mptfc.c:#include <linux/sort.h> ./lib/extable.c:#include <linux/sort.h> ./lib/sort.c:#include <linux/sort.h> ./fs/nfs_common/nfsacl.c:#include <linux/sort.h> ./fs/gfs2/glock.c:#include <linux/sort.h> ./fs/gfs2/inode.c:#include <linux/sort.h> ./fs/gfs2/quota.c:#include <linux/sort.h> ./fs/gfs2/dir.c:#include <linux/sort.h> ./fs/xfs/linux-2.6/xfs_linux.h:#include <linux/sort.h> ./mm/page_alloc.c:#include <linux/sort.h>

Lotta includes of the header. And does anybody use the one function in it? [/usr/src/linux-2.6] find . -name '*.c' | xargs grep 'sort(' | wc

     66     376    5054

[/usr/src/linux-2.6] find . -name '*.c' | xargs grep '[ ]sort(' | head
./arch/x86/kernel/mmconf-fam10h_64.c: sort(range, hi_mmio_num, sizeof(struct range), cmp_range, NULL);

./arch/sparc/prom/memory.c:     sort(sp_banks, num_ents, sizeof(struct sparc_phys_banks),
./arch/sparc64/mm/init.c:       sort(regs, ents, sizeof(struct linux_prom64_registers),
./arch/sparc64/mm/init.c:       sort(prom_trans, ents, sizeof(struct linux_prom_translation),

./arch/powerpc/kernel/module_32.c: sort((void *)hdr + sechdrs[i].sh_offset,
./arch/powerpc/kernel/module_64.c: sort((void *)sechdrs[i].sh_addr,
./arch/ia64/mm/extable.c: sort(start, finish - start, sizeof(struct exception_table_entry),
./kernel/cgroup.c: sort(pidarray, npids, sizeof(pid_t), cmppid, NULL);
./kernel/lockdep_proc.c: sort(data->stats, data->iter_end - data->iter,
./drivers/media/video/saa7134/saa7134-video.c: sort(col, cols, sizeof col[0], cliplist_cmp, NULL);

Looks like people call it too. OK, I admit I haven't gone and checked whether all of those have #ifdef-0 magic around them that render them dead code, but I suspect lots of them are live code...

What made you think it wasn't used?

#2 lore raw
In reply to Soumyadip Das Mahapatra
Quoted 4 lines · On Wed, 18 Jun 2008 20:39:38 +0200 (CEST) Soumyadip Das Mahapatra wrote:

Hello everybody,
I dont understand what is the significance of keeping
include/linux/sort.h and lib/sort.c while i think there is none using (#include<linux/sort.h>) it. Can anyone explaint it?

Did you check all of these?

./drivers/message/fusion/mptfc.c:56:#include <linux/sort.h> ./drivers/net/pppol2tp.c:92:#include <linux/sort.h> ./drivers/media/video/saa7134/saa7134-video.c:28:#include <linux/sort.h> ./drivers/media/video/v4l2-int-device.c:27:#include <linux/sort.h> ./fs/gfs2/glock.c:16:#include <linux/sort.h> ./fs/gfs2/dir.c:59:#include <linux/sort.h> ./fs/gfs2/quota.c:44:#include <linux/sort.h> ./fs/gfs2/inode.c:16:#include <linux/sort.h> ./fs/ubifs/find.c:29:#include <linux/sort.h> ./fs/nfs_common/nfsacl.c:28:#include <linux/sort.h> ./lib/extable.c:14:#include <linux/sort.h> ./arch/sparc/prom/memory.c:9:#include <linux/sort.h> ./arch/x86/kernel/test_nx.c:13:#include <linux/sort.h> ./arch/x86/kernel/mmconf-fam10h_64.c:11:#include <linux/sort.h> ./arch/x86/kernel/setup_64.c:44:#include <linux/sort.h> ./arch/x86/kernel/cpu/mtrr/main.c:40:#include <linux/sort.h> ./arch/sparc64/mm/init.c:25:#include <linux/sort.h> ./arch/powerpc/kernel/module_64.c:27:#include <linux/sort.h> ./arch/powerpc/kernel/module_32.c:27:#include <linux/sort.h> ./arch/ia64/mm/extable.c:8:#include <linux/sort.h> ./kernel/lockdep_proc.c:20:#include <linux/sort.h> ./kernel/cpuset.c:52:#include <linux/sort.h> ./kernel/cgroup.c:43:#include <linux/sort.h> ./mm/page_alloc.c:42:#include <linux/sort.h>

---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/