Skip to content

Commit 8e30bf3

Browse files
authored
ggml : fix compilation errors incurred by -Werror (#1227)
The -Werror warning option turns all warnings into errors. This PR makes the compiler happy to build ggml.c and whisper.cpp with the stricter option.
1 parent 99d3c10 commit 8e30bf3

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

ggml.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ static inline __m256 sum_i16_pairs_float(const __m256i x) {
663663
}
664664

665665
static inline __m256 mul_sum_us8_pairs_float(const __m256i ax, const __m256i sy) {
666-
#if __AVXVNNI__
666+
#ifdef __AVXVNNI__
667667
const __m256i zero = _mm256_setzero_si256();
668668
const __m256i summed_pairs = _mm256_dpbusd_epi32(zero, ax, sy);
669669
return _mm256_cvtepi32_ps(summed_pairs);
@@ -676,7 +676,7 @@ static inline __m256 mul_sum_us8_pairs_float(const __m256i ax, const __m256i sy)
676676

677677
// multiply int8_t, add results pairwise twice and return as float vector
678678
static inline __m256 mul_sum_i8_pairs_float(const __m256i x, const __m256i y) {
679-
#if __AVXVNNIINT8__
679+
#ifdef __AVXVNNIINT8__
680680
const __m256i zero = _mm256_setzero_si256();
681681
const __m256i summed_pairs = _mm256_dpbssd_epi32(zero, x, y);
682682
return _mm256_cvtepi32_ps(summed_pairs);
@@ -692,7 +692,7 @@ static inline __m256 mul_sum_i8_pairs_float(const __m256i x, const __m256i y) {
692692
static inline __m128i packNibbles( __m256i bytes )
693693
{
694694
// Move bits within 16-bit lanes from 0000_abcd_0000_efgh into 0000_0000_abcd_efgh
695-
#if __AVX512F__
695+
#ifdef __AVX512F__
696696
const __m256i bytes_srli_4 = _mm256_srli_epi16(bytes, 4); // 0000_0000_abcd_0000
697697
bytes = _mm256_or_si256(bytes, bytes_srli_4); // 0000_abcd_abcd_efgh
698698
return _mm256_cvtepi16_epi8(bytes); // abcd_efgh
@@ -4949,6 +4949,13 @@ struct ggml_tensor * ggml_set_name(struct ggml_tensor * tensor, const char * nam
49494949
return tensor;
49504950
}
49514951

4952+
#ifdef __GNUC__
4953+
#ifdef __MINGW32__
4954+
__attribute__((gnu_format(printf, 2, 3)))
4955+
#else
4956+
__attribute__((format(printf, 2, 3)))
4957+
#endif
4958+
#endif
49524959
struct ggml_tensor * ggml_format_name(struct ggml_tensor * tensor, const char * fmt, ...) {
49534960
va_list args;
49544961
va_start(args, fmt);

whisper.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "coreml/whisper-encoder.h"
44
#endif
55

6-
#if WHISPER_USE_OPENVINO
6+
#ifdef WHISPER_USE_OPENVINO
77
#include "openvino/whisper-openvino-encoder.h"
88
#endif
99

@@ -730,6 +730,13 @@ static void whisper_default_log(const char * text) {
730730

731731
static whisper_log_callback whisper_log = whisper_default_log;
732732

733+
#ifdef __GNUC__
734+
#ifdef __MINGW32__
735+
__attribute__((gnu_format(printf, 1, 2)))
736+
#else
737+
__attribute__((format(printf, 1, 2)))
738+
#endif
739+
#endif
733740
static void log(const char * fmt, ...) {
734741
if (!whisper_log) return;
735742
char buf[1024];
@@ -2446,7 +2453,7 @@ static void fft(const std::vector<float> & in, std::vector<float> & out) {
24462453
}
24472454

24482455
static bool hann_window(int length, bool periodic, std::vector<float> & output) {
2449-
if (output.size() < length) {
2456+
if (output.size() < static_cast<size_t>(length)) {
24502457
output.resize(length);
24512458
}
24522459
int offset = -1;

0 commit comments

Comments
 (0)