>> Would you like to achieve any improvements for automatic code beautification? >> https://github.com/coccinelle/coccinelle/issues/37 > > If you want to report a problem,
I became curious again if more contributors would become interested to influence a possibly known software situation a bit more. > you must include a semantic patch @replacement@ expression check, context, x1, x2; identifier action; @@ -if (check) - action(context, x1); -else - action(context, x2); +action(context, (check) ? x1 : x2); > and C code that gives an unsatisfactory result. Source file example: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/ksm.c?id=550d1f5bda33fa3b203d8cf8df1396825dbfd213#n2500 https://elixir.bootlin.com/linux/v5.2-rc7/source/mm/ksm.c#L2500 // SPDX-License-Identifier: GPL-2.0-only // Deleted part int __ksm_enter(struct mm_struct *mm) { struct mm_slot *mm_slot; int needs_wakeup; mm_slot = alloc_mm_slot(); if (!mm_slot) return -ENOMEM; /* Check ksm_run too? Would need tighter locking */ needs_wakeup = list_empty(&ksm_mm_head.mm_list); spin_lock(&ksm_mmlist_lock); insert_to_mm_slots_hash(mm, mm_slot); // Deleted part if (ksm_run & KSM_RUN_UNMERGE) list_add_tail(&mm_slot->mm_list, &ksm_mm_head.mm_list); else list_add_tail(&mm_slot->mm_list, &ksm_scan.mm_slot->mm_list); spin_unlock(&ksm_mmlist_lock); // Deleted part return 0; } // Deleted part Another test result: elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch ../janitor/use_call_with_ternary_operator1.cocci ksm-excerpt1.c … + list_add_tail(&mm_slot->mm_list, + (ksm_run & KSM_RUN_UNMERGE) ? &ksm_mm_head.mm_list : &ksm_scan.mm_slot->mm_list); … How likely is it that the combined source code for a single function parameter will fit into known line length limitations? Regards, Markus _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
