\u8fd9\u79cd\u7ed3\u6784\u4f53\u901a\u5e38\u88ab\u5d4c\u5165\u5230\u5176\u4ed6\u7ed3\u6784\u4f53\u4e2d\uff0c\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u611f\u5174\u8da3\u7684\u7ed3\u6784\u7c7b\u578b\u5236\u4f5c\u94fe\u8868\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5185\u6838\u8fd8\u63d0\u4f9b\u4e86\u5927\u91cf\u53ef\u7528\u4e8e\u904d\u5386\u548c\u64cd\u4f5c\u94fe\u8868\u7684\u51fd\u6570\u548c\u5b8f\u3002\u5176\u4e2d\u4e4b\u4e00\u662f list_for_each_entry()\uff0c\u8fd9\u662f\u4e00\u4e2a\u4f2a\u88c5\u6210\u63a7\u5236\u7ed3\u6784\u7684\u5b8f\u3002\u8981\u4e86\u89e3\u5982\u4f55\u4f7f\u7528\u6b64\u5b8f\uff0c\u8bf7\u5047\u8bbe\u5185\u6838\u5305\u542b\u5982\u4e0b\u7ed3\u6784\uff1a<\/p>\n
\r\nstruct foo {\r\n\r\n int fooness;\r\n\r\n struct list_head list;\r\n\r\n};\r\n<\/pre>\nlist \u6210\u5458\u53ef\u7528\u4e8e\u521b\u5efa foo \u7ed3\u6784\u4f53\u7684\u53cc\u5411\u94fe\u8868\uff0c\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u53eb\u505a foo_list \u7684\u7ed3\u6784\u58f0\u660e\u4f5c\u4e3a\u6b64\u7c7b\u94fe\u8868\u7684\u5934\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u53ef\u4ee5\u904d\u5386\u6b64\u5217\u8868\uff1a<\/p>\n
\r\nstruct foo *iterator;\r\n\r\nlist_for_each_entry(iterator, &foo_list, list) {\r\n\r\n do_something_with(iterator);\r\n\r\n}\r\n\r\n\/* Should not use iterator here *\/\r\n<\/pre>\nlist \u53c2\u6570\u544a\u8bc9\u5b8f\u5728 foo \u7ed3\u6784\u4e2d list_head \u7ed3\u6784\u4f53\u7684\u540d\u79f0\u3002\u6b64\u5faa\u73af\u5c06\u4e3a\u5217\u8868\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u6267\u884c\u4e00\u6b21\uff0c\u8fed\u4ee3\u5668\u6307\u5411\u8be5\u5143\u7d20\u3002\u7531\u6b64\u5bfc\u81f4\u4e86 USB \u5b50\u7cfb\u7edf\u4e2d\u7684\u4e00\u4e2a bug\uff1a\u4f20\u9012\u7ed9\u8be5\u5b8f\u7684\u8fed\u4ee3\u5668\u5728\u9000\u51fa\u5b8f\u540e\u8fd8\u80fd\u88ab\u4f7f\u7528\u3002<\/p>\n
Koschel \u901a\u8fc7\u91cd\u65b0\u7f16\u5199\u6709\u95ee\u9898\u7684\u4ee3\u7801\uff0c\u4ee5\u5728\u5faa\u73af\u540e\u505c\u6b62\u4f7f\u7528\u8fed\u4ee3\u5668\u6765\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n
\u4e0d\u8fc7 Linus \u5374\u5bf9\u8865\u4e01\u4fee\u590d\u7684\u95ee\u9898\u8868\u793a\u4e0d\u89e3\uff0c\u4e5f\u6ca1\u6709\u770b\u5230\u5b83\u4e0e\u9884\u6d4b\u6267\u884c\u6f0f\u6d1e\u7684\u5173\u7cfb\u3002Koschel \u5bf9\u6b64\u8fdb\u884c\u4e86\u8fdb\u4e00\u6b65\u89e3\u91ca\uff0c\u5bf9\u6b64 Linus \u8ba4\u4e3a\u8fd9\u53ea\u662f\u4e00\u4e2a\u666e\u901a\u7684 bug\u3002\u4f46\u4e0d\u4e45\u4e4b\u540e Linus \u53d1\u73b0\u4e86\u95ee\u9898\u7684\u6839\u6e90\u6240\u5728\uff1a\u4f20\u9012\u7ed9\u5217\u8868\u904d\u5386\u5b8f\u7684\u8fed\u4ee3\u5668\uff0c\u5fc5\u987b\u5728\u5faa\u73af\u672c\u8eab\u4e4b\u5916\u7684\u8303\u56f4\u5185\u58f0\u660e\u3002<\/p>\n
\u968f\u540e\uff0cLinus \u8ba4\u4e3a\u4e5f\u8bb8\u53ef\u4ee5\u91c7\u7528\u66f4\u76f4\u63a5\u7684\u4fee\u590d\u5982\u5757\u7ea7\u53d8\u91cf\u58f0\u660e\u3002\u4f46 C89 \u4e0d\u652f\u6301\uff0c\u800c 1999 \u5e74\u53d1\u5e03\u7684 C99 \u6807\u51c6\u652f\u6301\u3002\u6240\u4ee5 Linux \u5185\u6838\u4e5f\u8bb8\u662f\u65f6\u5019\u8f6c\u5411\u4f7f\u7528 C99 \u6807\u51c6\u4e86\u3002<\/p>\n
Linus \u8bf4\u5230\uff0c\u5185\u6838\u4ee3\u7801\u4e00\u76f4\u505c\u7559\u5728 C89 \u7684\u539f\u56e0\u4e4b\u4e00\u662f\u7f16\u8bd1\u5668 gcc \u7684\u65e7\u7248\u672c\u4f1a\u51fa\u73b0\u5947\u602a\u7684\u95ee\u9898\uff0c\u5bfc\u81f4\u521d\u59cb\u5316\u7a0b\u5e8f\u88ab\u7834\u574f\u3002\u4e0d\u8fc7\u73b0\u5728\u5185\u6838\u8981\u6c42\u7684 GCC \u6700\u4f4e\u7248\u672c\u5df2\u7ecf\u63d0\u9ad8\u5230\u4e86 v5.1\uff0c\u90a3\u4e9b bug \u53ef\u80fd\u4e0d\u518d\u76f8\u5173\u4e86\u3002<\/p>\n
\u53e6\u4e00\u4f4d\u5bc6\u5207\u5173\u6ce8\u67b6\u6784\u7f16\u8bd1\u5668\u95ee\u9898\u7684\u5185\u6838\u5f00\u53d1\u8005 Arnd Bergmann \u63d0\u8bae\u76f4\u63a5\u5347\u7ea7\u5230 C11 \u751a\u81f3 C2x\uff0c\u5c3d\u7ba1\u4ed6\u4e0d\u786e\u5b9a C11 \u662f\u5426\u4f1a\u5e26\u6765\u4efb\u4f55\u5bf9\u5185\u6838\u6709\u7528\u7684\u65b0\u5185\u5bb9\u3002\u4e0d\u8fc7\u5982\u679c\u5347\u7ea7\u5230 C17 \u6216 C2x\uff0c\u4f1a\u7834\u574f\u5bf9 gcc-5\/6\/7 \u7684\u652f\u6301\uff0c\u56e0\u6b64\u5347\u7ea7\u5230 C11 \u66f4\u5bb9\u6613\u5b9e\u73b0\uff0c\u800c\u4e14\u8de8\u8d8a\u592a\u5927\u5185\u6838\u793e\u533a\u672a\u5fc5\u63a5\u53d7\u3002<\/p>\n
Linus \u8d5e\u6210\u4e86\u8fd9\u4e2a\u60f3\u6cd5\uff0c\u5728 Bergmann \u786e\u8ba4\u5e94\u8be5\u53ef\u4ee5\u8fd9\u6837\u505a\u4e4b\u540e\uff0cLinus \u5ba3\u5e03\u5c06\u5728\u4e0b\u4e00\u4e2a\u5185\u6838\u7248\u672c v5.18 \u4e2d\u5c1d\u8bd5\u4f7f\u7528 C11 \u6807\u51c6\u3002\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u4e0b\u4e00\u4e2a\u5185\u6838\u7248\u672c\u4f7f\u7528\u7684 C \u8bed\u8a00\u6807\u51c6\u6709\u671b\u5347\u7ea7\u5230 C11\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u867d\u7136 Linux \u5185\u6838\u5728\u5feb\u901f\u53d1\u5c55\uff0c\u4f46\u5b83\u540c\u65f6\u4f9d\u8d56\u7740\u4e00\u4e9b\u975e\u5e38\u53e4\u8001\u7684\u5de5\u5177\uff0c\u5176\u4e2d\u4e4b\u4e00\u5c31\u662f\u5185\u6838\u4ee3\u7801\u4ecd\u5728\u4f7f\u7528 1989 \u5e74 […]<\/p>\n","protected":false},"author":370,"featured_media":224095,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-240993","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/240993","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/370"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=240993"}],"version-history":[{"count":2,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/240993\/revisions"}],"predecessor-version":[{"id":241307,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/240993\/revisions\/241307"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/224095"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=240993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=240993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=240993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}