[READ-ONLY] Mirror of https://github.com/VibeDevelopers/atheme. Modified fork of atheme IRC Services www.vibetalk.net/
0

Configure Feed

Select the types of activity you want to include in your feed.

attributes.h: add support for the 'fallthrough' statement attribute

GCC parses literal code comments of the form /* FALLTHROUGH */ but
Clang does not; this statement attribute is a more concrete declaration
of intent supported by both compilers, and yet still readable by humans.

Supported since at least Clang v5, and since GCC v7.1.

Add the new statement attribute where missing to the codebase to finally
silence the unannotated fallthrough warnings emitted during Clang build.

Aaron Jones (Jun 12, 2020, 8:26 AM UTC) 7eb6b16b 5a4feaa7

+72 -11
+14
include/atheme/attributes.h
··· 38 38 # if __has_attribute(__diagnose_if__) 39 39 # define ATHEME_ATTR_HAS_DIAGNOSE_IF 1 40 40 # endif 41 + # if __has_attribute(__fallthrough__) 42 + # define ATHEME_ATTR_HAS_FALLTHROUGH 1 43 + # endif 41 44 # if __has_attribute(__format__) 42 45 # define ATHEME_ATTR_HAS_FORMAT 1 43 46 # endif ··· 118 121 # define ATHEME_FATTR_DIAGNOSE_IF(cond, msg, type) __attribute__((__diagnose_if__((cond), (msg), (type)))) 119 122 #else 120 123 # define ATHEME_FATTR_DIAGNOSE_IF(cond, msg, type) /* No 'diagnose_if' function attribute support */ 124 + #endif 125 + 126 + /* Prevent the compiler from warning about fall-through in switch() case statements. This one is a little bit 127 + * unique, in that its name is shorter because it is intended to be used within a block of code multiple times, 128 + * and so saves a lot of typing and eyesore. Its name is still prefixed with ATHEME_ however, to prevent any 129 + * unintended collision with a FALLTHROUGH macro declared in the header files of any library we end up using. 130 + */ 131 + #ifdef ATHEME_ATTR_HAS_FALLTHROUGH 132 + # define ATHEME_FALLTHROUGH __attribute__((__fallthrough__)) 133 + #else 134 + # define ATHEME_FALLTHROUGH /* No 'fallthrough' statement attribute support */ 121 135 #endif 122 136 123 137 /* Have the compiler verify printf(3) or scanf(3) format tokens in the parameter position given by 'fmt' against the
+9
modules/botserv/main.c
··· 610 610 } 611 611 else 612 612 command_fail(si, fault_badparams, _("\2%s\2 is an invalid realname, not changing it."), parv[4]); 613 + 614 + ATHEME_FALLTHROUGH; 615 + 613 616 case 4: 614 617 sfree(bot->host); 615 618 bot->host = sstrdup(parv[3]); 619 + ATHEME_FALLTHROUGH; 620 + 616 621 case 3: 617 622 // XXX: we really need an is_valid_user(), but this is close enough. --nenolod 618 623 if (is_valid_username(parv[2])) { ··· 620 625 bot->user = sstrndup(parv[2], USERLEN); 621 626 } else 622 627 command_fail(si, fault_badparams, _("\2%s\2 is an invalid username, not changing it."), parv[2]); 628 + 629 + ATHEME_FALLTHROUGH; 630 + 623 631 case 2: 624 632 sfree(bot->nick); 625 633 bot->nick = sstrdup(parv[1]); 626 634 break; 635 + 627 636 default: 628 637 command_fail(si, fault_needmoreparams, STR_INVALID_PARAMS, "BOT CHANGE"); 629 638 command_fail(si, fault_needmoreparams, _("Syntax: BOT CHANGE <oldnick> <newnick> [<user> [<host> [<real>]]]"));
+28 -4
modules/crypto/pbkdf2v2.c
··· 61 61 switch (prf) 62 62 { 63 63 case PBKDF2_PRF_HMAC_MD5_S64: 64 + ATHEME_FALLTHROUGH; 64 65 case PBKDF2_PRF_HMAC_SHA1_S64: 66 + ATHEME_FALLTHROUGH; 65 67 case PBKDF2_PRF_HMAC_SHA2_256_S64: 68 + ATHEME_FALLTHROUGH; 66 69 case PBKDF2_PRF_HMAC_SHA2_512_S64: 70 + ATHEME_FALLTHROUGH; 67 71 case PBKDF2_PRF_SCRAM_MD5_S64: 72 + ATHEME_FALLTHROUGH; 68 73 case PBKDF2_PRF_SCRAM_SHA1_S64: 74 + ATHEME_FALLTHROUGH; 69 75 case PBKDF2_PRF_SCRAM_SHA2_256_S64: 76 + ATHEME_FALLTHROUGH; 70 77 case PBKDF2_PRF_SCRAM_SHA2_512_S64: 71 78 return true; 72 79 } ··· 80 87 switch (dbe->a) 81 88 { 82 89 case PBKDF2_PRF_SCRAM_MD5: 90 + ATHEME_FALLTHROUGH; 83 91 case PBKDF2_PRF_SCRAM_MD5_S64: 84 92 dbe->scram = true; 85 - /* FALLTHROUGH */ 93 + ATHEME_FALLTHROUGH; 86 94 case PBKDF2_PRF_HMAC_MD5: 95 + ATHEME_FALLTHROUGH; 87 96 case PBKDF2_PRF_HMAC_MD5_S64: 88 97 dbe->md = DIGALG_MD5; 89 98 dbe->dl = DIGEST_MDLEN_MD5; 90 99 break; 91 100 92 101 case PBKDF2_PRF_SCRAM_SHA1: 102 + ATHEME_FALLTHROUGH; 93 103 case PBKDF2_PRF_SCRAM_SHA1_S64: 94 104 dbe->scram = true; 95 - /* FALLTHROUGH */ 105 + ATHEME_FALLTHROUGH; 96 106 case PBKDF2_PRF_HMAC_SHA1: 107 + ATHEME_FALLTHROUGH; 97 108 case PBKDF2_PRF_HMAC_SHA1_S64: 98 109 dbe->md = DIGALG_SHA1; 99 110 dbe->dl = DIGEST_MDLEN_SHA1; 100 111 break; 101 112 102 113 case PBKDF2_PRF_SCRAM_SHA2_256: 114 + ATHEME_FALLTHROUGH; 103 115 case PBKDF2_PRF_SCRAM_SHA2_256_S64: 104 116 dbe->scram = true; 105 - /* FALLTHROUGH */ 117 + ATHEME_FALLTHROUGH; 106 118 case PBKDF2_PRF_HMAC_SHA2_256: 119 + ATHEME_FALLTHROUGH; 107 120 case PBKDF2_PRF_HMAC_SHA2_256_S64: 108 121 dbe->md = DIGALG_SHA2_256; 109 122 dbe->dl = DIGEST_MDLEN_SHA2_256; 110 123 break; 111 124 112 125 case PBKDF2_PRF_SCRAM_SHA2_512: 126 + ATHEME_FALLTHROUGH; 113 127 case PBKDF2_PRF_SCRAM_SHA2_512_S64: 114 128 dbe->scram = true; 115 - /* FALLTHROUGH */ 129 + ATHEME_FALLTHROUGH; 116 130 case PBKDF2_PRF_HMAC_SHA2_512: 131 + ATHEME_FALLTHROUGH; 117 132 case PBKDF2_PRF_HMAC_SHA2_512_S64: 118 133 dbe->md = DIGALG_SHA2_512; 119 134 dbe->dl = DIGEST_MDLEN_SHA2_512; ··· 319 334 switch (dbe->a) 320 335 { 321 336 case PBKDF2_PRF_HMAC_SHA1: 337 + ATHEME_FALLTHROUGH; 322 338 case PBKDF2_PRF_HMAC_SHA1_S64: 339 + ATHEME_FALLTHROUGH; 323 340 case PBKDF2_PRF_SCRAM_SHA1: 341 + ATHEME_FALLTHROUGH; 324 342 case PBKDF2_PRF_SCRAM_SHA1_S64: 325 343 dbe->a = PBKDF2_PRF_SCRAM_SHA1_S64; 326 344 break; 327 345 328 346 case PBKDF2_PRF_HMAC_SHA2_256: 347 + ATHEME_FALLTHROUGH; 329 348 case PBKDF2_PRF_HMAC_SHA2_256_S64: 349 + ATHEME_FALLTHROUGH; 330 350 case PBKDF2_PRF_SCRAM_SHA2_256: 351 + ATHEME_FALLTHROUGH; 331 352 case PBKDF2_PRF_SCRAM_SHA2_256_S64: 332 353 dbe->a = PBKDF2_PRF_SCRAM_SHA2_256_S64; 333 354 break; 334 355 335 356 case PBKDF2_PRF_HMAC_SHA2_512: 357 + ATHEME_FALLTHROUGH; 336 358 case PBKDF2_PRF_HMAC_SHA2_512_S64: 359 + ATHEME_FALLTHROUGH; 337 360 case PBKDF2_PRF_SCRAM_SHA2_512: 361 + ATHEME_FALLTHROUGH; 338 362 case PBKDF2_PRF_SCRAM_SHA2_512_S64: 339 363 dbe->a = PBKDF2_PRF_SCRAM_SHA2_512_S64; 340 364 break;
+19 -6
modules/protocol/p10-generic.c
··· 729 729 { 730 730 switch (*p) 731 731 { 732 - case '+': dir = MTYPE_ADD; break; 733 - case '-': dir = MTYPE_DEL; break; 732 + case '+': 733 + dir = MTYPE_ADD; 734 + break; 735 + 736 + case '-': 737 + dir = MTYPE_DEL; 738 + break; 739 + 734 740 case 'l': 735 - if (dir == MTYPE_DEL) 736 - break; 737 - /* FALLTHROUGH */ 738 - case 'b': case 'k': case 'o': case 'v': 741 + if (dir == MTYPE_DEL) 742 + break; 743 + 744 + ATHEME_FALLTHROUGH; 745 + case 'b': 746 + ATHEME_FALLTHROUGH; 747 + case 'k': 748 + ATHEME_FALLTHROUGH; 749 + case 'o': 750 + ATHEME_FALLTHROUGH; 751 + case 'v': 739 752 i++; 740 753 } 741 754 }
+2 -1
modules/proxyscan/dnsbl.c
··· 287 287 288 288 case DNSBL_ACT_NOTIFY: 289 289 notice(svs->nick, u->nick, "Your IP address %s is listed in DNS Blacklist %s", u->ip, blptr->host); 290 - // FALLTHROUGH 290 + ATHEME_FALLTHROUGH; 291 + 291 292 case DNSBL_ACT_SNOOP: 292 293 slog(LG_INFO, "DNSBL: \2%s\2!%s@%s [%s] is listed in DNS Blacklist %s.", u->nick, u->user, u->host, u->gecos, blptr->host); 293 294 break;