dark-Matter

sample.patch

Aug 2nd, 2020 (edited)
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. From 5b7051cdd8567d7fc0d23ac787e9c1c967804a4f Mon Sep 17 00:00:00 2001
  2. From: abcd xy <abc@xyz.com>
  3. Date: Wed, 29 Jul 2020 14:30:16 +0530
  4. Subject: [PATCH 02/02] Task 08: add foo file
  5.  
  6. THIS IS A FALSE PATCH.
  7.  
  8. list_for_each_entry_safe is able to handle an empty list.
  9. The only effect of avoiding the loop is not initializing the
  10. index variable.
  11. Drop list_empty tests in cases where these variables are not
  12. used.
  13.  
  14. Note that list_for_each_entry_safe is defined in terms of
  15. list_first_entry, which indicates that it should not be used on an
  16. empty list. But in list_for_each_entry_safe, the element obtained by
  17. list_first_entry is not really accessed, only the address of its
  18. list_head field is compared to the address of the list head, so the
  19. list_first_entry is safe.
  20.  
  21. The semantic patch that makes this change is as follows (with another
  22. variant for the no brace case): (http://coccinelle.lip6.fr/)
  23.  
  24. <smpl>
  25. @@
  26. expression x,e;
  27. iterator name list_for_each_entry_safe;
  28. statement S;
  29. identifier i,j;
  30. @@
  31. -if (!(list_empty(x))) {
  32. list_for_each_entry_safe(i,j,x,...) S
  33. - }
  34. ... when != i
  35. when != j
  36. (
  37. i = e;
  38. |
  39. ? j = e;
  40. )
  41. </smpl>
  42.  
  43. Signed-off-by: abcd xy <abc@xyz.com>
  44.  
  45. ---
  46. sound/soc/intel/atom/sst/sst_loader.c | 10 ++++------
  47. sound/soc/intel/skylake/skl-pcm.c | 8 +++-----
  48. sound/soc/intel/skylake/skl-topology.c | 5 ++---
  49. 3 files changed, 9 insertions(+), 14 deletions(-)
  50.  
  51. diff --git a/sound/soc/intel/atom/sst/sst_loader.c b/sound/soc/intel/atom/sst/sst_loader.c
  52. index 8ad0ca7..fc91a30 100644
  53. --- a/sound/soc/intel/atom/sst/sst_loader.c
  54. +++ b/sound/soc/intel/atom/sst/sst_loader.c
  55. @@ -276,12 +276,10 @@ void sst_memcpy_free_resources(struct intel_sst_drv *sst_drv_ctx)
  56. struct sst_memcpy_list *listnode, *tmplistnode;
  57.  
  58. /* Free the list */
  59. - if (!list_empty(&sst_drv_ctx->memcpy_list)) {
  60. - list_for_each_entry_safe(listnode, tmplistnode,
  61. - &sst_drv_ctx->memcpy_list, memcpylist) {
  62. - list_del(&listnode->memcpylist);
  63. - kfree(listnode);
  64. - }
  65. + list_for_each_entry_safe(listnode, tmplistnode,
  66. + &sst_drv_ctx->memcpy_list, memcpylist) {
  67. + list_del(&listnode->memcpylist);
  68. + kfree(listnode);
  69. }
  70. }
  71.  
  72. diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
  73. index 89dcccd..9e15b06 100644
  74. --- a/sound/soc/intel/skylake/skl-pcm.c
  75. +++ b/sound/soc/intel/skylake/skl-pcm.c
  76. @@ -1509,11 +1509,9 @@ int skl_platform_unregister(struct device *dev)
  77. struct skl_dev *skl = bus_to_skl(bus);
  78. struct skl_module_deferred_bind *modules, *tmp;
  79.  
  80. - if (!list_empty(&skl->bind_list)) {
  81. - list_for_each_entry_safe(modules, tmp, &skl->bind_list, node) {
  82. - list_del(&modules->node);
  83. - kfree(modules);
  84. - }
  85. + list_for_each_entry_safe(modules, tmp, &skl->bind_list, node) {
  86. + list_del(&modules->node);
  87. + kfree(modules);
  88. }
  89.  
  90. kfree(skl->dais);
  91. diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
  92. index b9aab47..b7d2d97 100644
  93. --- a/sound/soc/intel/skylake/skl-topology.c
  94. +++ b/sound/soc/intel/skylake/skl-topology.c
  95. @@ -3773,9 +3773,8 @@ void skl_tplg_exit(struct snd_soc_component *component, struct hdac_bus *bus)
  96. struct skl_dev *skl = bus_to_skl(bus);
  97. struct skl_pipeline *ppl, *tmp;
  98.  
  99. - if (!list_empty(&skl->ppl_list))
  100. - list_for_each_entry_safe(ppl, tmp, &skl->ppl_list, node)
  101. - list_del(&ppl->node);
  102. + list_for_each_entry_safe(ppl, tmp, &skl->ppl_list, node)
  103. + list_del(&ppl->node);
  104.  
  105. /* clean up topology */
  106. snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL);
Add Comment
Please, Sign In to add comment