]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
treewide: Change list_sort to use const pointers
authorSami Tolvanen <samitolvanen@google.com>
Thu, 8 Apr 2021 18:28:34 +0000 (11:28 -0700)
committerKees Cook <keescook@chromium.org>
Thu, 8 Apr 2021 23:04:22 +0000 (16:04 -0700)
list_sort() internally casts the comparison function passed to it
to a different type with constant struct list_head pointers, and
uses this pointer to call the functions, which trips indirect call
Control-Flow Integrity (CFI) checking.

Instead of removing the consts, this change defines the
list_cmp_func_t type and changes the comparison function types of
all list_sort() callers to use const pointers, thus avoiding type
mismatches.

Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210408182843.1754385-10-samitolvanen@google.com
41 files changed:
arch/arm64/kvm/vgic/vgic-its.c
arch/arm64/kvm/vgic/vgic.c
block/blk-mq-sched.c
block/blk-mq.c
drivers/acpi/nfit/core.c
drivers/acpi/numa/hmat.c
drivers/clk/keystone/sci-clk.c
drivers/gpu/drm/drm_modes.c
drivers/gpu/drm/i915/gt/intel_engine_user.c
drivers/gpu/drm/i915/gvt/debugfs.c
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
drivers/gpu/drm/radeon/radeon_cs.c
drivers/infiniband/hw/usnic/usnic_uiom_interval_tree.c
drivers/interconnect/qcom/bcm-voter.c
drivers/md/raid5.c
drivers/misc/sram.c
drivers/nvme/host/core.c
drivers/pci/controller/cadence/pcie-cadence-host.c
drivers/spi/spi-loopback-test.c
fs/btrfs/raid56.c
fs/btrfs/tree-log.c
fs/btrfs/volumes.c
fs/ext4/fsmap.c
fs/gfs2/glock.c
fs/gfs2/log.c
fs/gfs2/lops.c
fs/iomap/buffered-io.c
fs/ubifs/gc.c
fs/ubifs/replay.c
fs/xfs/scrub/bitmap.c
fs/xfs/xfs_bmap_item.c
fs/xfs/xfs_buf.c
fs/xfs/xfs_extent_busy.c
fs/xfs/xfs_extent_busy.h
fs/xfs/xfs_extfree_item.c
fs/xfs/xfs_refcount_item.c
fs/xfs/xfs_rmap_item.c
include/linux/list_sort.h
lib/list_sort.c
lib/test_list_sort.c
net/tipc/name_table.c

index 40cbaca81333439f5d873056da432306e9f2ddaa..b9518f94bd43557f6545d2064ac605bfaeabeedc 100644 (file)
@@ -2190,8 +2190,8 @@ static int vgic_its_restore_ite(struct vgic_its *its, u32 event_id,
        return offset;
 }
 
-static int vgic_its_ite_cmp(void *priv, struct list_head *a,
-                           struct list_head *b)
+static int vgic_its_ite_cmp(void *priv, const struct list_head *a,
+                           const struct list_head *b)
 {
        struct its_ite *itea = container_of(a, struct its_ite, ite_list);
        struct its_ite *iteb = container_of(b, struct its_ite, ite_list);
@@ -2329,8 +2329,8 @@ static int vgic_its_restore_dte(struct vgic_its *its, u32 id,
        return offset;
 }
 
-static int vgic_its_device_cmp(void *priv, struct list_head *a,
-                              struct list_head *b)
+static int vgic_its_device_cmp(void *priv, const struct list_head *a,
+                              const struct list_head *b)
 {
        struct its_device *deva = container_of(a, struct its_device, dev_list);
        struct its_device *devb = container_of(b, struct its_device, dev_list);
index 1c597c9885fa7a115824df4ad66a1fbada87f129..15b666200f0b4be8a70f10952f77ce6d1e1eff40 100644 (file)
@@ -255,7 +255,8 @@ static struct kvm_vcpu *vgic_target_oracle(struct vgic_irq *irq)
  * Return negative if "a" sorts before "b", 0 to preserve order, and positive
  * to sort "b" before "a".
  */
-static int vgic_irq_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int vgic_irq_cmp(void *priv, const struct list_head *a,
+                       const struct list_head *b)
 {
        struct vgic_irq *irqa = container_of(a, struct vgic_irq, ap_list);
        struct vgic_irq *irqb = container_of(b, struct vgic_irq, ap_list);
index e1e997af89a0d6f664d103b275a752e85fd7e3a2..3ebd6f10f728e9be433cd5e63147a84b40774029 100644 (file)
@@ -75,7 +75,8 @@ void blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx)
        blk_mq_run_hw_queue(hctx, true);
 }
 
-static int sched_rq_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int sched_rq_cmp(void *priv, const struct list_head *a,
+                       const struct list_head *b)
 {
        struct request *rqa = container_of(a, struct request, queuelist);
        struct request *rqb = container_of(b, struct request, queuelist);
index d4d7c1caa439666f212c63df86a2a61a81a68ca9..4e3a70ab5be19b7f2645d50263007be69e449d78 100644 (file)
@@ -1895,7 +1895,8 @@ void blk_mq_insert_requests(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx,
        spin_unlock(&ctx->lock);
 }
 
-static int plug_rq_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int plug_rq_cmp(void *priv, const struct list_head *a,
+                      const struct list_head *b)
 {
        struct request *rqa = container_of(a, struct request, queuelist);
        struct request *rqb = container_of(b, struct request, queuelist);
index 8c5dde628405a8b6900daaaa03bb070b3685804c..d15e3ee93b5b6dbe62e4f17787ee1f7e8954d027 100644 (file)
@@ -1195,7 +1195,8 @@ static int __nfit_mem_init(struct acpi_nfit_desc *acpi_desc,
        return 0;
 }
 
-static int nfit_mem_cmp(void *priv, struct list_head *_a, struct list_head *_b)
+static int nfit_mem_cmp(void *priv, const struct list_head *_a,
+               const struct list_head *_b)
 {
        struct nfit_mem *a = container_of(_a, typeof(*a), list);
        struct nfit_mem *b = container_of(_b, typeof(*b), list);
index cb73a5d6ea76da0b0790b7ba6d81c7bcd7626704..137a5dd880c26a5a352345419d22cdc0e36c0d90 100644 (file)
@@ -558,7 +558,8 @@ static bool hmat_update_best(u8 type, u32 value, u32 *best)
        return updated;
 }
 
-static int initiator_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int initiator_cmp(void *priv, const struct list_head *a,
+                        const struct list_head *b)
 {
        struct memory_initiator *ia;
        struct memory_initiator *ib;
index aaf31abe1c8ff38e8fcb131f7725e2c30095a870..7e1b136e71ae0f6daf048c73a452439b1dcb7725 100644 (file)
@@ -503,8 +503,8 @@ static int ti_sci_scan_clocks_from_fw(struct sci_clk_provider *provider)
 
 #else
 
-static int _cmp_sci_clk_list(void *priv, struct list_head *a,
-                            struct list_head *b)
+static int _cmp_sci_clk_list(void *priv, const struct list_head *a,
+                            const struct list_head *b)
 {
        struct sci_clk *ca = container_of(a, struct sci_clk, node);
        struct sci_clk *cb = container_of(b, struct sci_clk, node);
index 1ac67d4505e073933dd79d9e2ad21cf96f78844c..6662d0457ad65bcf491c9ef27efb805df67f6ce6 100644 (file)
@@ -1290,7 +1290,8 @@ EXPORT_SYMBOL(drm_mode_prune_invalid);
  * Negative if @lh_a is better than @lh_b, zero if they're equivalent, or
  * positive if @lh_b is better than @lh_a.
  */
-static int drm_mode_compare(void *priv, struct list_head *lh_a, struct list_head *lh_b)
+static int drm_mode_compare(void *priv, const struct list_head *lh_a,
+                           const struct list_head *lh_b)
 {
        struct drm_display_mode *a = list_entry(lh_a, struct drm_display_mode, head);
        struct drm_display_mode *b = list_entry(lh_b, struct drm_display_mode, head);
index 34e6096f196ed8eb647cfcce68faf427a23e60cf..da21d2a10cc94222ba8e1dd2ad35a2e10a6df16d 100644 (file)
@@ -49,7 +49,8 @@ static const u8 uabi_classes[] = {
        [VIDEO_ENHANCEMENT_CLASS] = I915_ENGINE_CLASS_VIDEO_ENHANCE,
 };
 
-static int engine_cmp(void *priv, struct list_head *A, struct list_head *B)
+static int engine_cmp(void *priv, const struct list_head *A,
+                     const struct list_head *B)
 {
        const struct intel_engine_cs *a =
                container_of((struct rb_node *)A, typeof(*a), uabi_node);
index 62e6a14ad58ef78caaa0875c59d70d0059a07368..9f1c209d9251107f95cad7ea4c28e62cf505439f 100644 (file)
@@ -41,7 +41,7 @@ struct diff_mmio {
 
 /* Compare two diff_mmio items. */
 static int mmio_offset_compare(void *priv,
-       struct list_head *a, struct list_head *b)
+       const struct list_head *a, const struct list_head *b)
 {
        struct diff_mmio *ma;
        struct diff_mmio *mb;
index c1adea8765a97cffbfe474ddbb1eafe697cac2b7..52b9c39e015592d8d992a5ea34b3f05024b7bdd7 100644 (file)
@@ -1076,7 +1076,8 @@ static int igt_ppgtt_shrink_boom(void *arg)
        return exercise_ppgtt(arg, shrink_boom);
 }
 
-static int sort_holes(void *priv, struct list_head *A, struct list_head *B)
+static int sort_holes(void *priv, const struct list_head *A,
+                     const struct list_head *B)
 {
        struct drm_mm_node *a = list_entry(A, typeof(*a), hole_stack);
        struct drm_mm_node *b = list_entry(B, typeof(*b), hole_stack);
index 35e937d39b51893e270029d4b7d566ce6546c8a5..1a5c3db1d53bc7818e24b31a18be71f8acaf443f 100644 (file)
@@ -393,8 +393,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
        return 0;
 }
 
-static int cmp_size_smaller_first(void *priv, struct list_head *a,
-                                 struct list_head *b)
+static int cmp_size_smaller_first(void *priv, const struct list_head *a,
+                                 const struct list_head *b)
 {
        struct radeon_bo_list *la = list_entry(a, struct radeon_bo_list, tv.head);
        struct radeon_bo_list *lb = list_entry(b, struct radeon_bo_list, tv.head);
index d399523206c78b083c42557134ca858afba1325d..29d71267af786e32534b7209a436eea3412e0ab5 100644 (file)
@@ -83,7 +83,8 @@ usnic_uiom_interval_node_alloc(long int start, long int last, int ref_cnt,
        return interval;
 }
 
-static int interval_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int interval_cmp(void *priv, const struct list_head *a,
+                       const struct list_head *b)
 {
        struct usnic_uiom_interval_node *node_a, *node_b;
 
index 1cc565bce2f4da956be6a358d04a7c18657d5996..d1591a28b74388cbfb5e9df0bbaae65727425139 100644 (file)
@@ -39,7 +39,7 @@ struct bcm_voter {
        u32 tcs_wait;
 };
 
-static int cmp_vcd(void *priv, struct list_head *a, struct list_head *b)
+static int cmp_vcd(void *priv, const struct list_head *a, const struct list_head *b)
 {
        const struct qcom_icc_bcm *bcm_a = list_entry(a, struct qcom_icc_bcm, list);
        const struct qcom_icc_bcm *bcm_b = list_entry(b, struct qcom_icc_bcm, list);
index 5d57a5bd171fa1a82beb539f9fa53df95152c659..841e1c1aa5e63aa51677794f0cf578fc9635b65d 100644 (file)
@@ -953,7 +953,8 @@ static void dispatch_bio_list(struct bio_list *tmp)
                submit_bio_noacct(bio);
 }
 
-static int cmp_stripe(void *priv, struct list_head *a, struct list_head *b)
+static int cmp_stripe(void *priv, const struct list_head *a,
+                     const struct list_head *b)
 {
        const struct r5pending_data *da = list_entry(a,
                                struct r5pending_data, sibling);
index 6c1a23cb3e8c0fa8ef1f5bf8b871a10c763fa894..202bf951e9095ff6a51038c7ddefb7e6a269587a 100644 (file)
@@ -144,8 +144,8 @@ static void sram_free_partitions(struct sram_dev *sram)
        }
 }
 
-static int sram_reserve_cmp(void *priv, struct list_head *a,
-                                       struct list_head *b)
+static int sram_reserve_cmp(void *priv, const struct list_head *a,
+                                       const struct list_head *b)
 {
        struct sram_reserve *ra = list_entry(a, struct sram_reserve, list);
        struct sram_reserve *rb = list_entry(b, struct sram_reserve, list);
index 0896e21642bebabf4450a5694b9196b77174d91b..5eaaa51a5e308d6d2de41259a953bb1a9de2967a 100644 (file)
@@ -3855,7 +3855,8 @@ out_unlock:
        return ret;
 }
 
-static int ns_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int ns_cmp(void *priv, const struct list_head *a,
+               const struct list_head *b)
 {
        struct nvme_ns *nsa = container_of(a, struct nvme_ns, list);
        struct nvme_ns *nsb = container_of(b, struct nvme_ns, list);
index 73dcf8cf98fbf43efeeb6e54001ee25bb1b757bb..ae1c55503513a910af620620c70997e2913d71c6 100644 (file)
@@ -345,7 +345,8 @@ static int cdns_pcie_host_bar_config(struct cdns_pcie_rc *rc,
        return 0;
 }
 
-static int cdns_pcie_host_dma_ranges_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int cdns_pcie_host_dma_ranges_cmp(void *priv, const struct list_head *a,
+                                        const struct list_head *b)
 {
        struct resource_entry *entry1, *entry2;
 
index df981e55c24c99b618fa4a0e2849bfaab6b88ebc..f1cf2232f0b5e2b7567fb0314501c43fb3e5c6ae 100644 (file)
@@ -454,7 +454,8 @@ struct rx_ranges {
        u8 *end;
 };
 
-static int rx_ranges_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int rx_ranges_cmp(void *priv, const struct list_head *a,
+                        const struct list_head *b)
 {
        struct rx_ranges *rx_a = list_entry(a, struct rx_ranges, list);
        struct rx_ranges *rx_b = list_entry(b, struct rx_ranges, list);
index 8c31357f08ed9eb91784db8e468b3b5f49037e34..f4139de63b2e112236a2372625233cd72967b92e 100644 (file)
@@ -1634,7 +1634,8 @@ struct btrfs_plug_cb {
 /*
  * rbios on the plug list are sorted for easier merging.
  */
-static int plug_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int plug_cmp(void *priv, const struct list_head *a,
+                   const struct list_head *b)
 {
        struct btrfs_raid_bio *ra = container_of(a, struct btrfs_raid_bio,
                                                 plug_list);
index 92a3686277918a67e22cdda63575344138830f30..00a88bd8105e25b6d0ec0e06d6f00aed70ce55af 100644 (file)
@@ -4136,7 +4136,8 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
        return ret;
 }
 
-static int extent_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int extent_cmp(void *priv, const struct list_head *a,
+                     const struct list_head *b)
 {
        struct extent_map *em1, *em2;
 
index 1c6810bbaf8b5445c74913af2f5cd23387be0e5c..912dd8b9f156c1ebb6a7565ec07e6b9603290cf5 100644 (file)
@@ -1224,7 +1224,8 @@ static int open_fs_devices(struct btrfs_fs_devices *fs_devices,
        return 0;
 }
 
-static int devid_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int devid_cmp(void *priv, const struct list_head *a,
+                    const struct list_head *b)
 {
        struct btrfs_device *dev1, *dev2;
 
index 4c2a9fe3006723f4ee1fc84e461d1782322ec054..4493ef0c715e9d1a1e8166feefc0a532339f6dd0 100644 (file)
@@ -354,8 +354,8 @@ static unsigned int ext4_getfsmap_find_sb(struct super_block *sb,
 
 /* Compare two fsmap items. */
 static int ext4_getfsmap_compare(void *priv,
-                                struct list_head *a,
-                                struct list_head *b)
+                                const struct list_head *a,
+                                const struct list_head *b)
 {
        struct ext4_fsmap *fa;
        struct ext4_fsmap *fb;
index 9567520d79f798b0d6fb1b180328241158acf6ff..c06a6cdf05de607327444ec75e5f4d4bafb98b9a 100644 (file)
@@ -1732,7 +1732,8 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret)
        spin_unlock(&gl->gl_lockref.lock);
 }
 
-static int glock_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int glock_cmp(void *priv, const struct list_head *a,
+                    const struct list_head *b)
 {
        struct gfs2_glock *gla, *glb;
 
index 6410281546f924942dd6a3f734a357e8eadd300a..88649b43fcffbd7b93d187759fd6258393fac83a 100644 (file)
@@ -695,7 +695,7 @@ void log_flush_wait(struct gfs2_sbd *sdp)
        }
 }
 
-static int ip_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int ip_cmp(void *priv, const struct list_head *a, const struct list_head *b)
 {
        struct gfs2_inode *ipa, *ipb;
 
index a82f4747aa8d5eaa05038e9ae324eabad53b48c3..b4809967efc675966d36f2346194368ad4a98168 100644 (file)
@@ -634,7 +634,8 @@ static void gfs2_check_magic(struct buffer_head *bh)
        kunmap_atomic(kaddr);
 }
 
-static int blocknr_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int blocknr_cmp(void *priv, const struct list_head *a,
+                      const struct list_head *b)
 {
        struct gfs2_bufdata *bda, *bdb;
 
index 414769a6ad113af77a363e12518d8cfc711a164e..0129e6bab98570a1a68b1392b23e788066567a32 100644 (file)
@@ -1155,7 +1155,8 @@ iomap_ioend_try_merge(struct iomap_ioend *ioend, struct list_head *more_ioends,
 EXPORT_SYMBOL_GPL(iomap_ioend_try_merge);
 
 static int
-iomap_ioend_compare(void *priv, struct list_head *a, struct list_head *b)
+iomap_ioend_compare(void *priv, const struct list_head *a,
+               const struct list_head *b)
 {
        struct iomap_ioend *ia = container_of(a, struct iomap_ioend, io_list);
        struct iomap_ioend *ib = container_of(b, struct iomap_ioend, io_list);
index a4aaeea63893e2939303a4aead1dcf92f4519eca..dc3e26e9ed7b2b905f97f46d7f2b68f542ba8024 100644 (file)
@@ -102,7 +102,8 @@ static int switch_gc_head(struct ubifs_info *c)
  * This function compares data nodes @a and @b. Returns %1 if @a has greater
  * inode or block number, and %-1 otherwise.
  */
-static int data_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int data_nodes_cmp(void *priv, const struct list_head *a,
+                         const struct list_head *b)
 {
        ino_t inuma, inumb;
        struct ubifs_info *c = priv;
@@ -145,8 +146,8 @@ static int data_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
  * first and sorted by length in descending order. Directory entry nodes go
  * after inode nodes and are sorted in ascending hash valuer order.
  */
-static int nondata_nodes_cmp(void *priv, struct list_head *a,
-                            struct list_head *b)
+static int nondata_nodes_cmp(void *priv, const struct list_head *a,
+                            const struct list_head *b)
 {
        ino_t inuma, inumb;
        struct ubifs_info *c = priv;
index 0f8a6a16421b4a7db2ec84bd979f94cf75923eae..4d17e5382b7410e6886c6337dd6eac9221fdf7d5 100644 (file)
@@ -298,8 +298,8 @@ static int apply_replay_entry(struct ubifs_info *c, struct replay_entry *r)
  * entries @a and @b by comparing their sequence numer.  Returns %1 if @a has
  * greater sequence number and %-1 otherwise.
  */
-static int replay_entries_cmp(void *priv, struct list_head *a,
-                             struct list_head *b)
+static int replay_entries_cmp(void *priv, const struct list_head *a,
+                             const struct list_head *b)
 {
        struct ubifs_info *c = priv;
        struct replay_entry *ra, *rb;
index f88694f22d059ac5a99286aa8e74c272b788e2e4..813b5f21911387e32045ba65daadafd9a51e1389 100644 (file)
@@ -63,8 +63,8 @@ xbitmap_init(
 static int
 xbitmap_range_cmp(
        void                    *priv,
-       struct list_head        *a,
-       struct list_head        *b)
+       const struct list_head  *a,
+       const struct list_head  *b)
 {
        struct xbitmap_range    *ap;
        struct xbitmap_range    *bp;
index 2344757ede63c0dfa5ce1d15d11bd380d8d2ce8e..e3a691937e92f08258b2a4dfc20ce9d145356735 100644 (file)
@@ -265,8 +265,8 @@ xfs_trans_log_finish_bmap_update(
 static int
 xfs_bmap_update_diff_items(
        void                            *priv,
-       struct list_head                *a,
-       struct list_head                *b)
+       const struct list_head          *a,
+       const struct list_head          *b)
 {
        struct xfs_bmap_intent          *ba;
        struct xfs_bmap_intent          *bb;
index 37a1d12762d8f54c3c438bf1f30eaf5086b8ccd3..592800c8852f45f8794405e7b738ec2afb938c22 100644 (file)
@@ -2124,9 +2124,9 @@ xfs_buf_delwri_queue(
  */
 static int
 xfs_buf_cmp(
-       void            *priv,
-       struct list_head *a,
-       struct list_head *b)
+       void                    *priv,
+       const struct list_head  *a,
+       const struct list_head  *b)
 {
        struct xfs_buf  *ap = container_of(a, struct xfs_buf, b_list);
        struct xfs_buf  *bp = container_of(b, struct xfs_buf, b_list);
index ef17c1f6db32242bfbafc5e5f36fbfe661f306fc..a4075685d9ebaf25f407163313438b601e7b739b 100644 (file)
@@ -629,8 +629,8 @@ xfs_extent_busy_wait_all(
 int
 xfs_extent_busy_ag_cmp(
        void                    *priv,
-       struct list_head        *l1,
-       struct list_head        *l2)
+       const struct list_head  *l1,
+       const struct list_head  *l2)
 {
        struct xfs_extent_busy  *b1 =
                container_of(l1, struct xfs_extent_busy, list);
index 990ab3891971730d3bfe2e060191d4e14ecaa9f0..8aea07100092397f4e1f5754c9b806ce5138cb9c 100644 (file)
@@ -58,7 +58,8 @@ void
 xfs_extent_busy_wait_all(struct xfs_mount *mp);
 
 int
-xfs_extent_busy_ag_cmp(void *priv, struct list_head *a, struct list_head *b);
+xfs_extent_busy_ag_cmp(void *priv, const struct list_head *a,
+       const struct list_head *b);
 
 static inline void xfs_extent_busy_sort(struct list_head *list)
 {
index 93223ebb33721ed3fb8429d7e3f34e92935484c3..2424230ca2c3f6db7dae99b991532022bbfa1f36 100644 (file)
@@ -397,8 +397,8 @@ xfs_trans_free_extent(
 static int
 xfs_extent_free_diff_items(
        void                            *priv,
-       struct list_head                *a,
-       struct list_head                *b)
+       const struct list_head          *a,
+       const struct list_head          *b)
 {
        struct xfs_mount                *mp = priv;
        struct xfs_extent_free_item     *ra;
index 07ebccbbf4dfab8e270b9c4aca46800d1fceff2f..746f4eda724ce35d1d6adc50c399b3ba14cefb38 100644 (file)
@@ -269,8 +269,8 @@ xfs_trans_log_finish_refcount_update(
 static int
 xfs_refcount_update_diff_items(
        void                            *priv,
-       struct list_head                *a,
-       struct list_head                *b)
+       const struct list_head          *a,
+       const struct list_head          *b)
 {
        struct xfs_mount                *mp = priv;
        struct xfs_refcount_intent      *ra;
index 49cebd68b6727b7eb378e7c8c6111308a78771ee..dc4f0c9f0897af385abfe02bf851a6422eb6bd97 100644 (file)
@@ -337,8 +337,8 @@ xfs_trans_log_finish_rmap_update(
 static int
 xfs_rmap_update_diff_items(
        void                            *priv,
-       struct list_head                *a,
-       struct list_head                *b)
+       const struct list_head          *a,
+       const struct list_head          *b)
 {
        struct xfs_mount                *mp = priv;
        struct xfs_rmap_intent          *ra;
index 20f178c24e9d13db3ddb4d628f1085831410b30b..453105f74e050451b4c65748218b9fbd03b5db0f 100644 (file)
@@ -6,8 +6,9 @@
 
 struct list_head;
 
+typedef int __attribute__((nonnull(2,3))) (*list_cmp_func_t)(void *,
+               const struct list_head *, const struct list_head *);
+
 __attribute__((nonnull(2,3)))
-void list_sort(void *priv, struct list_head *head,
-              int (*cmp)(void *priv, struct list_head *a,
-                         struct list_head *b));
+void list_sort(void *priv, struct list_head *head, list_cmp_func_t cmp);
 #endif
index 52f0c258c895a0fb62ef1384774a38036648e848..a926d96ffd44d3b6e90b2b5c71bfbae18e9fe19d 100644 (file)
@@ -7,16 +7,13 @@
 #include <linux/list_sort.h>
 #include <linux/list.h>
 
-typedef int __attribute__((nonnull(2,3))) (*cmp_func)(void *,
-               struct list_head const *, struct list_head const *);
-
 /*
  * Returns a list organized in an intermediate format suited
  * to chaining of merge() calls: null-terminated, no reserved or
  * sentinel head node, "prev" links not maintained.
  */
 __attribute__((nonnull(2,3,4)))
-static struct list_head *merge(void *priv, cmp_func cmp,
+static struct list_head *merge(void *priv, list_cmp_func_t cmp,
                                struct list_head *a, struct list_head *b)
 {
        struct list_head *head, **tail = &head;
@@ -52,7 +49,7 @@ static struct list_head *merge(void *priv, cmp_func cmp,
  * throughout.
  */
 __attribute__((nonnull(2,3,4,5)))
-static void merge_final(void *priv, cmp_func cmp, struct list_head *head,
+static void merge_final(void *priv, list_cmp_func_t cmp, struct list_head *head,
                        struct list_head *a, struct list_head *b)
 {
        struct list_head *tail = head;
@@ -185,9 +182,7 @@ static void merge_final(void *priv, cmp_func cmp, struct list_head *head,
  * 2^(k+1) - 1 (second merge of case 5 when x == 2^(k-1) - 1).
  */
 __attribute__((nonnull(2,3)))
-void list_sort(void *priv, struct list_head *head,
-               int (*cmp)(void *priv, struct list_head *a,
-                       struct list_head *b))
+void list_sort(void *priv, struct list_head *head, list_cmp_func_t cmp)
 {
        struct list_head *list = head->next, *pending = NULL;
        size_t count = 0;       /* Count of pending */
@@ -227,7 +222,7 @@ void list_sort(void *priv, struct list_head *head,
                if (likely(bits)) {
                        struct list_head *a = *tail, *b = a->prev;
 
-                       a = merge(priv, (cmp_func)cmp, b, a);
+                       a = merge(priv, cmp, b, a);
                        /* Install the merged result in place of the inputs */
                        a->prev = b->prev;
                        *tail = a;
@@ -249,10 +244,10 @@ void list_sort(void *priv, struct list_head *head,
 
                if (!next)
                        break;
-               list = merge(priv, (cmp_func)cmp, pending, list);
+               list = merge(priv, cmp, pending, list);
                pending = next;
        }
        /* The final merge, rebuilding prev links */
-       merge_final(priv, (cmp_func)cmp, head, pending, list);
+       merge_final(priv, cmp, head, pending, list);
 }
 EXPORT_SYMBOL(list_sort);
index 1f017d3b610ee3fbfcee18a73c348d96e3e66a92..00daaf23316f4881f857d7d0aecfa3746f41da4c 100644 (file)
@@ -56,7 +56,8 @@ static int __init check(struct debug_el *ela, struct debug_el *elb)
        return 0;
 }
 
-static int __init cmp(void *priv, struct list_head *a, struct list_head *b)
+static int __init cmp(void *priv, const struct list_head *a,
+                     const struct list_head *b)
 {
        struct debug_el *ela, *elb;
 
index ee5ac40ea2b618d8459497f946e91ee7cc0cf7ab..f8141443f2e21bed29658345969cdf5e3e4a0e9d 100644 (file)
@@ -397,8 +397,8 @@ static struct publication *tipc_service_remove_publ(struct service_range *sr,
  * Code reused: time_after32() for the same purpose
  */
 #define publication_after(pa, pb) time_after32((pa)->id, (pb)->id)
-static int tipc_publ_sort(void *priv, struct list_head *a,
-                         struct list_head *b)
+static int tipc_publ_sort(void *priv, const struct list_head *a,
+                         const struct list_head *b)
 {
        struct publication *pa, *pb;