diff options
| author | Jan Djärv | 2013-09-23 09:12:01 +0200 |
|---|---|---|
| committer | Jan Djärv | 2013-09-23 09:12:01 +0200 |
| commit | 8762e52438d46d81e518179e4f9bd8a939463ddb (patch) | |
| tree | 33a25414302599a9dbe3d2a4144927e128f57af1 /src | |
| parent | 332153538c3268edb9154fbe29a6fdc5e012e595 (diff) | |
| download | emacs-8762e52438d46d81e518179e4f9bd8a939463ddb.tar.gz emacs-8762e52438d46d81e518179e4f9bd8a939463ddb.zip | |
Suppress some unhelpful warnings when using clang.
* configure.ac: With clang, check for and use -Wno-switch,
-Wno-tautological-constant-out-of-range-compare and -Wno-pointer-sign.
* conf_post.h(assume): Use __builtin_unreachable for clang.
* src/filelock.c (lock_file_1): Rearrange to remove compiler warning
about excess arguments to snprintf.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/conf_post.h | 8 | ||||
| -rw-r--r-- | src/filelock.c | 16 |
3 files changed, 27 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 668ebeb8537..29cd8676584 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-09-23 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * filelock.c (lock_file_1): Rearrange to remove compiler warning | ||
| 4 | about excess arguments to snprintf. | ||
| 5 | |||
| 6 | * conf_post.h(assume): Use __builtin_unreachable for clang. | ||
| 7 | |||
| 1 | 2013-09-23 Juanma Barranquero <lekktu@gmail.com> | 8 | 2013-09-23 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 9 | ||
| 3 | * w32console.c (initialize_w32_display): Remove unused variable hlinfo. | 10 | * w32console.c (initialize_w32_display): Remove unused variable hlinfo. |
diff --git a/src/conf_post.h b/src/conf_post.h index 14af38ce70b..7d4e1f43ed7 100644 --- a/src/conf_post.h +++ b/src/conf_post.h | |||
| @@ -248,12 +248,20 @@ extern void _DebPrint (const char *fmt, ...); | |||
| 248 | # define FLEXIBLE_ARRAY_MEMBER 1 | 248 | # define FLEXIBLE_ARRAY_MEMBER 1 |
| 249 | #endif | 249 | #endif |
| 250 | 250 | ||
| 251 | #ifdef __clang__ | ||
| 252 | # ifndef __has_builtin | ||
| 253 | # define __has_builtin(x) 0 | ||
| 254 | # endif | ||
| 255 | #endif | ||
| 256 | |||
| 251 | /* assume(cond) tells the compiler (and lint) that a certain condition | 257 | /* assume(cond) tells the compiler (and lint) that a certain condition |
| 252 | * will always hold, and that it should optimize (or check) accordingly. */ | 258 | * will always hold, and that it should optimize (or check) accordingly. */ |
| 253 | #if defined lint | 259 | #if defined lint |
| 254 | # define assume(cond) ((cond) ? (void) 0 : abort ()) | 260 | # define assume(cond) ((cond) ? (void) 0 : abort ()) |
| 255 | #elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __GNUC__ > 4 | 261 | #elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __GNUC__ > 4 |
| 256 | # define assume(cond) ((cond) || (__builtin_unreachable(), 0)) | 262 | # define assume(cond) ((cond) || (__builtin_unreachable(), 0)) |
| 263 | #elif defined (__clang__) && __has_builtin (__builtin_unreachable) | ||
| 264 | # define assume(cond) ((cond) || (__builtin_unreachable(), 0)) | ||
| 257 | #elif defined __MSC_VER | 265 | #elif defined __MSC_VER |
| 258 | # define assume(cond) __assume ((cond)) | 266 | # define assume(cond) __assume ((cond)) |
| 259 | #else | 267 | #else |
diff --git a/src/filelock.c b/src/filelock.c index df72eff5950..2f53047f526 100644 --- a/src/filelock.c +++ b/src/filelock.c | |||
| @@ -459,10 +459,18 @@ lock_file_1 (char *lfname, bool force) | |||
| 459 | char lock_info_str[MAX_LFINFO + 1]; | 459 | char lock_info_str[MAX_LFINFO + 1]; |
| 460 | printmax_t pid = getpid (); | 460 | printmax_t pid = getpid (); |
| 461 | 461 | ||
| 462 | if (sizeof lock_info_str | 462 | if (boot) |
| 463 | <= snprintf (lock_info_str, sizeof lock_info_str, | 463 | { |
| 464 | boot ? "%s@%s.%"pMd":%"pMd : "%s@%s.%"pMd, | 464 | if (sizeof lock_info_str |
| 465 | user_name, host_name, pid, boot)) | 465 | <= snprintf (lock_info_str, sizeof lock_info_str, |
| 466 | "%s@%s.%"pMd":%"pMd, | ||
| 467 | user_name, host_name, pid, boot)) | ||
| 468 | return ENAMETOOLONG; | ||
| 469 | } | ||
| 470 | else if (sizeof lock_info_str | ||
| 471 | <= snprintf (lock_info_str, sizeof lock_info_str, | ||
| 472 | "%s@%s.%"pMd, | ||
| 473 | user_name, host_name, pid)) | ||
| 466 | return ENAMETOOLONG; | 474 | return ENAMETOOLONG; |
| 467 | 475 | ||
| 468 | return create_lock_file (lfname, lock_info_str, force); | 476 | return create_lock_file (lfname, lock_info_str, force); |