{"id":35244071,"url":"https://github.com/felipec/good-taste","last_synced_at":"2026-03-27T02:45:16.480Z","repository":{"id":56758479,"uuid":"456050358","full_name":"felipec/good-taste","owner":"felipec","description":"An illustration of good taste in code","archived":false,"fork":false,"pushed_at":"2024-08-02T05:14:46.000Z","size":58,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-03T05:32:34.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"SCSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felipec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-06T03:55:41.000Z","updated_at":"2024-08-02T05:14:49.000Z","dependencies_parsed_at":"2024-04-02T18:32:29.761Z","dependency_job_id":"c4d04726-79c2-4f0f-9de5-b2e08247076a","html_url":"https://github.com/felipec/good-taste","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/felipec/good-taste","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipec%2Fgood-taste","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipec%2Fgood-taste/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipec%2Fgood-taste/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipec%2Fgood-taste/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felipec","download_url":"https://codeload.github.com/felipec/good-taste/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipec%2Fgood-taste/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31011922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T02:33:22.146Z","status":"ssl_error","status_checked_at":"2026-03-27T02:33:21.763Z","response_time":164,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-30T05:41:41.495Z","updated_at":"2026-03-27T02:45:16.473Z","avatar_url":"https://github.com/felipec.png","language":"SCSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is an explanation of how to write code with good taste by using a single\nlinked list example inspired by Mark Kirchner's project\n[linked-list-good-taste], which in turn was inspired by a comment Linus\nTorvalds made in his [TED talk][ted] in 2016.\n\nIn [part 1] we start by turning this typical implementation:\n\n```c\nvoid remove_list_entry(node **head, node *entry)\n{\n\tnode *prev, *walk;\n\n\tprev = NULL;\n\twalk = *head;\n\n\t// Walk the list\n\n\twhile (walk != entry) {\n\t\tprev = walk;\n\t\twalk = walk-\u003enext;\n\t}\n\n\t// Remove the entry by updating the\n\t// head or the previous entry\n\n\tif (!prev)\n\t\t*head = entry-\u003enext;\n\telse\n\t\tprev-\u003enext = entry-\u003enext;\n}\n```\n\ninto this:\n\n```c\nvoid remove_list_entry(node **head, node *entry)\n{\n\tnode **p = head;\n\twhile (*p != entry)\n\t\tp = \u0026(*p)-\u003enext;\n\t*p = entry-\u003enext;\n}\n```\n\nIn [part 2] we then explore how a real library (GLib) does it and improve it to:\n\n```c\nGSList *g_slist_remove_link(GSList *list, GSList *link)\n{\n\tGSList **p = \u0026list;\n\n\twhile (*p) {\n\t\tif (*p == link) {\n\t\t\t*p = (*p)-\u003enext;\n\t\t\tbreak;\n\t\t}\n\n\t\tp = \u0026(*p)-\u003enext;\n\t}\n\n\treturn list;\n}\n```\n\nAnd finally in [part 3] we explore how Linux does it, and arrive to:\n\n```c\nvoid llist_del(struct llist_head *list, struct llist_node *entry)\n{\n\tstruct llist_node *p;\n\n\tllist_for_each(p, (struct llist_node *)list) {\n\t\tif (p-\u003enext != entry) continue;\n\t\tp-\u003enext = entry-\u003enext;\n\t\treturn;\n\t}\n}\n```\n\nWhich is vastly superior, and in good taste.\n\n[linked-list-good-taste]: https://github.com/mkirchner/linked-list-good-taste\n[ted]: https://youtu.be/o8NPllzkFhE?t=858\n[part 1]: https://felipec.github.io/good-taste/parts/1.html\n[part 2]: https://felipec.github.io/good-taste/parts/2.html\n[part 3]: https://felipec.github.io/good-taste/parts/3.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipec%2Fgood-taste","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelipec%2Fgood-taste","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipec%2Fgood-taste/lists"}