git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 1/4] connect.c: mark die_initial_contact() NORETURN

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 14, 2018, 19:19 UTC
Message-ID
<20180414191946.30674-2-avarab@gmail.com>
In-Reply-To
<20180414191946.30674-1-avarab@gmail.com>
From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>

There is a series running in parallel with this one that adds code like this

    switch (...) {
    case ...:
        die_initial_contact();
    case ...:

There is nothing wrong with this. There is no actual falling through. But since gcc is not that smart and gcc 7.x introduces -Wimplicit-fallthrough, it raises a false alarm in this case.

This class of warnings may be useful elsewhere, so instead of suppressing the whole class, let's try to fix just this code. gcc is smart enough to realize that no execution can continue after a NORETURN function call and no longer raises the warning.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 connect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/connect.c b/connect.c
index c3a014c5ba..49eca46462 100644
--- a/connect.c
+++ b/connect.c
@@ -46,7 +46,7 @@ int check_ref_type(const struct ref *ref, int flags)
 	return check_ref(ref->name, flags);
 }
 
-static void die_initial_contact(int unexpected)
+static NORETURN void die_initial_contact(int unexpected)
 {
 	if (unexpected)
 		die(_("The remote end hung up upon initial contact"));
-- 
2.17.0.290.gded63e768a
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 42 of 47 in “travis-ci: enable more warnings on travis linux-gcc job”
  1. travis-ci: enable more warnings on travis linux-gcc jobNguyễn Thái Ngọc Duy, Mar 3, 2018
  2. travis-ci: enable more warnings on travis linux-gcc jobNguyễn Thái Ngọc Duy, Mar 16, 2018
  3. Jeff KingMar 16, 2018
  4. Duy NguyenMar 17, 2018
  5. Lars SchneiderMar 17, 2018
  6. Duy NguyenMar 17, 2018
  7. Jeff KingMar 17, 2018
  8. Jeff KingMar 17, 2018
  9. Junio C HamanoMar 17, 2018
  10. Makefile: detect compiler and enable more warnings in DEVELOPER=1Nguyễn Thái Ngọc Duy, Mar 18, 2018
  11. Eric SunshineMar 18, 2018
  12. Duy NguyenMar 18, 2018
  13. Jeff KingMar 18, 2018
  14. Eric SunshineMar 18, 2018
  15. Jeff KingMar 18, 2018
  16. Eric SunshineMar 18, 2018
  17. Jeff KingMar 18, 2018
  18. Duy NguyenMar 18, 2018
  19. Duy NguyenMar 18, 2018
  20. Ramsay JonesMar 18, 2018
  21. Duy NguyenMar 19, 2018
  22. Jeff KingMar 20, 2018
  23. Makefile: detect compiler and enable more warnings in DEVELOPER=1Nguyễn Thái Ngọc Duy, Mar 24, 2018
  24. Eric SunshineMar 25, 2018
  25. Junio C HamanoMar 26, 2018
  26. Duy NguyenMar 27, 2018
  27. Junio C HamanoMar 27, 2018
  28. 0/3 Enable more compiler warnings for devsNguyễn Thái Ngọc Duy, Mar 29, 2018
  29. 3/3 Makefile: add EAGER_DEVELOPER modeNguyễn Thái Ngọc Duy, Mar 29, 2018
  30. 2/3 Makefile: detect compiler and enable more warnings in DEVELOPER=1Nguyễn Thái Ngọc Duy, Mar 29, 2018
  31. 1/3 connect.c: mark die_initial_contact() NORETURNNguyễn Thái Ngọc Duy, Mar 29, 2018
  32. 4/3 Makefile: untangle DEVELOPER and -WerrorÆvar Arnfjörð Bjarmason, Mar 31, 2018
  33. Duy NguyenMar 31, 2018
  34. Ævar Arnfjörð BjarmasonApr 3, 2018
  35. Duy NguyenApr 3, 2018
  36. Jeff KingApr 6, 2018
  37. Duy NguyenApr 7, 2018
  38. Ævar Arnfjörð BjarmasonApr 7, 2018
  39. Duy NguyenApr 7, 2018
  40. Ævar Arnfjörð BjarmasonApr 7, 2018
  41. 0/4 Make DEVELOPER more more flexible with DEVOPTSÆvar Arnfjörð Bjarmason, Apr 14, 2018
  42. 1/4 connect.c: mark die_initial_contact() NORETURNÆvar Arnfjörð Bjarmason, Apr 14, 2018
  43. 2/4 Makefile: detect compiler and enable more warnings in DEVELOPER=1Ævar Arnfjörð Bjarmason, Apr 14, 2018
  44. 3/4 Makefile: add a DEVOPTS to suppress -Werror under DEVELOPERÆvar Arnfjörð Bjarmason, Apr 14, 2018
  45. 4/4 Makefile: add a DEVOPTS to get all of -WextraÆvar Arnfjörð Bjarmason, Apr 14, 2018
  46. Junio C HamanoApr 16, 2018
  47. Jeff KingMar 17, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.