aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-03 21:34:17 +0200
committerMax Kellermann <max@duempel.org>2013-08-03 21:34:17 +0200
commit67f591a9ce60651da41afc499bd9a22e25314e35 (patch)
tree0eeeba50880b52317f326c73587a7cb4a5c93b32
parent105b431e4cd5416b44ed3fb68e5944ad59bd8221 (diff)
downloadmpd-67f591a9ce60651da41afc499bd9a22e25314e35.tar.gz
mpd-67f591a9ce60651da41afc499bd9a22e25314e35.tar.xz
mpd-67f591a9ce60651da41afc499bd9a22e25314e35.zip
gcc.h: add macro gcc_unreachable()
Diffstat (limited to '')
-rw-r--r--src/DecoderControl.cxx2
-rw-r--r--src/OutputInit.cxx2
-rw-r--r--src/ReplayGainConfig.cxx3
-rw-r--r--src/audio_format.c2
-rw-r--r--src/audio_format.h2
-rw-r--r--src/decoder/FlacPcm.cxx2
-rw-r--r--src/filter/ChainFilterPlugin.cxx1
-rw-r--r--src/gcc.h6
-rw-r--r--src/output/AlsaOutputPlugin.cxx2
-rw-r--r--src/output/JackOutputPlugin.cxx1
-rw-r--r--src/pcm/PcmMix.cxx6
-rw-r--r--src/pcm/PcmVolume.cxx3
12 files changed, 18 insertions, 14 deletions
diff --git a/src/DecoderControl.cxx b/src/DecoderControl.cxx
index a8f41f564..6721bd55a 100644
--- a/src/DecoderControl.cxx
+++ b/src/DecoderControl.cxx
@@ -99,7 +99,7 @@ decoder_control::IsCurrentSong(const Song *_song) const
}
assert(false);
- return false;
+ gcc_unreachable();
}
void
diff --git a/src/OutputInit.cxx b/src/OutputInit.cxx
index da243b54a..6dd40cd67 100644
--- a/src/OutputInit.cxx
+++ b/src/OutputInit.cxx
@@ -123,7 +123,7 @@ audio_output_load_mixer(struct audio_output *ao,
}
assert(false);
- return NULL;
+ gcc_unreachable();
}
bool
diff --git a/src/ReplayGainConfig.cxx b/src/ReplayGainConfig.cxx
index d86c70053..ea5054bae 100644
--- a/src/ReplayGainConfig.cxx
+++ b/src/ReplayGainConfig.cxx
@@ -55,9 +55,8 @@ replay_gain_get_mode_string(void)
return "album";
}
- /* unreachable */
assert(false);
- return "off";
+ gcc_unreachable();
}
bool
diff --git a/src/audio_format.c b/src/audio_format.c
index 45d94a853..cfe3a4cae 100644
--- a/src/audio_format.c
+++ b/src/audio_format.c
@@ -69,7 +69,7 @@ sample_format_to_string(enum sample_format format)
/* unreachable */
assert(false);
- return "?";
+ gcc_unreachable();
}
const char *
diff --git a/src/audio_format.h b/src/audio_format.h
index f9b176bc1..642eaa52a 100644
--- a/src/audio_format.h
+++ b/src/audio_format.h
@@ -253,7 +253,7 @@ sample_format_size(enum sample_format format)
}
assert(false);
- return 0;
+ gcc_unreachable();
}
/**
diff --git a/src/decoder/FlacPcm.cxx b/src/decoder/FlacPcm.cxx
index 82896bd24..17a13edda 100644
--- a/src/decoder/FlacPcm.cxx
+++ b/src/decoder/FlacPcm.cxx
@@ -104,7 +104,7 @@ flac_convert(void *dest,
case SAMPLE_FORMAT_FLOAT:
case SAMPLE_FORMAT_DSD:
case SAMPLE_FORMAT_UNDEFINED:
- /* unreachable */
assert(false);
+ gcc_unreachable();
}
}
diff --git a/src/filter/ChainFilterPlugin.cxx b/src/filter/ChainFilterPlugin.cxx
index c8666615f..ac0f10980 100644
--- a/src/filter/ChainFilterPlugin.cxx
+++ b/src/filter/ChainFilterPlugin.cxx
@@ -93,6 +93,7 @@ ChainFilter::CloseUntil(const Filter *until)
/* this assertion fails if #until does not exist (anymore) */
assert(false);
+ gcc_unreachable();
}
static const struct audio_format *
diff --git a/src/gcc.h b/src/gcc.h
index 2282ff5e6..1bd770597 100644
--- a/src/gcc.h
+++ b/src/gcc.h
@@ -79,6 +79,12 @@
#endif
+#if defined(__GNUC__) || defined(__clang__)
+#define gcc_unreachable() __builtin_unreachable()
+#else
+#define gcc_unreachable()
+#endif
+
#ifdef __cplusplus
#ifdef __GNUC__
diff --git a/src/output/AlsaOutputPlugin.cxx b/src/output/AlsaOutputPlugin.cxx
index 17fc91d1a..7d0e9e09c 100644
--- a/src/output/AlsaOutputPlugin.cxx
+++ b/src/output/AlsaOutputPlugin.cxx
@@ -257,7 +257,7 @@ get_bitformat(enum sample_format sample_format)
}
assert(false);
- return SND_PCM_FORMAT_UNKNOWN;
+ gcc_unreachable();
}
static snd_pcm_format_t
diff --git a/src/output/JackOutputPlugin.cxx b/src/output/JackOutputPlugin.cxx
index 3bc9cee8f..4f21b36f8 100644
--- a/src/output/JackOutputPlugin.cxx
+++ b/src/output/JackOutputPlugin.cxx
@@ -696,6 +696,7 @@ mpd_jack_write_samples(JackOutput *jd, const void *src,
default:
assert(false);
+ gcc_unreachable();
}
}
diff --git a/src/pcm/PcmMix.cxx b/src/pcm/PcmMix.cxx
index 8435c0c2a..b92258a83 100644
--- a/src/pcm/PcmMix.cxx
+++ b/src/pcm/PcmMix.cxx
@@ -110,9 +110,8 @@ pcm_add_vol(void *buffer1, const void *buffer2, size_t size,
return true;
}
- /* unreachable */
assert(false);
- return false;
+ gcc_unreachable();
}
template<typename T, typename U, unsigned bits>
@@ -184,9 +183,8 @@ pcm_add(void *buffer1, const void *buffer2, size_t size,
return true;
}
- /* unreachable */
assert(false);
- return false;
+ gcc_unreachable();
}
bool
diff --git a/src/pcm/PcmVolume.cxx b/src/pcm/PcmVolume.cxx
index 556ab9925..c22017ddd 100644
--- a/src/pcm/PcmVolume.cxx
+++ b/src/pcm/PcmVolume.cxx
@@ -188,7 +188,6 @@ pcm_volume(void *buffer, size_t length,
return true;
}
- /* unreachable */
assert(false);
- return false;
+ gcc_unreachable();
}