Skip to content

Commit

Permalink
libbacktrace: use __attribute__((__fallthrough__))
Browse files Browse the repository at this point in the history
Use an attribute rather than a comment when falling through a switch case.

	* internal.h (ATTRIBUTE_FALLTHROUGH): Define.
	* elf.c (elf_zlib_inflate): Use ATTRIBUTE_FALLTHROUGH.
  • Loading branch information
ianlancetaylor committed Oct 20, 2020
1 parent 5009c11 commit 73eb180
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 8 additions & 8 deletions elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2081,10 +2081,10 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
{
case 6:
*plen++ = prev;
/* fallthrough */
ATTRIBUTE_FALLTHROUGH;
case 5:
*plen++ = prev;
/* fallthrough */
ATTRIBUTE_FALLTHROUGH;
case 4:
*plen++ = prev;
}
Expand Down Expand Up @@ -2115,22 +2115,22 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
{
case 10:
*plen++ = 0;
/* fallthrough */
ATTRIBUTE_FALLTHROUGH;
case 9:
*plen++ = 0;
/* fallthrough */
ATTRIBUTE_FALLTHROUGH;
case 8:
*plen++ = 0;
/* fallthrough */
ATTRIBUTE_FALLTHROUGH;
case 7:
*plen++ = 0;
/* fallthrough */
ATTRIBUTE_FALLTHROUGH;
case 6:
*plen++ = 0;
/* fallthrough */
ATTRIBUTE_FALLTHROUGH;
case 5:
*plen++ = 0;
/* fallthrough */
ATTRIBUTE_FALLTHROUGH;
case 4:
*plen++ = 0;
}
Expand Down
8 changes: 8 additions & 0 deletions internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ POSSIBILITY OF SUCH DAMAGE. */
# endif
#endif

#ifndef ATTRIBUTE_FALLTHROUGH
# if (GCC_VERSION >= 7000)
# define ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
# else
# define ATTRIBUTE_FALLTHROUGH
# endif
#endif

#ifndef HAVE_SYNC_FUNCTIONS

/* Define out the sync functions. These should never be called if
Expand Down

0 comments on commit 73eb180

Please sign in to comment.