Skip to content

Commit

Permalink
core: Marked mmk_panic with noreturn for correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
Snaipe committed Apr 30, 2016
1 parent 8306548 commit 5ccd3a9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
37 changes: 37 additions & 0 deletions src/common.h
@@ -0,0 +1,37 @@
/*
* The MIT License (MIT)
*
* Copyright © 2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef COMMON_H_
# define COMMON_H_

# if __STDC_VERSION__ >= 201112L
# include <stdnoreturn.h>
# elif defined __GNUC__
# define noreturn __attribute__((noreturn))
# elif defined _MSC_VER
# define noreturn __declspec(noreturn)
# else
# define noreturn
# endif

#endif /* !COMMON_H_ */
2 changes: 1 addition & 1 deletion src/vitals.c
Expand Up @@ -131,7 +131,7 @@ void mmk_fprintf(FILE *f, const char *str, ...)
va_end(vl);
}

void mmk_panic(const char *str, ...)
noreturn void mmk_panic(const char *str, ...)
{
va_list vl;
va_start(vl, str);
Expand Down
3 changes: 2 additions & 1 deletion src/vitals.h
Expand Up @@ -26,6 +26,7 @@

# include <stddef.h>
# include "mimick/unmocked.h"
# include "common.h"
# include "plt.h"

/* string functions that are notoriously replaced by sse2 variants are
Expand All @@ -40,7 +41,7 @@ char *mmk_strncpy(char *dst, const char *src, size_t n);
size_t mmk_strlen(const char *s);
int mmk_isspace(int c);

void mmk_panic(const char *, ...);
noreturn void mmk_panic(const char *, ...);

void mmk_init_vital_functions(plt_ctx ctx);

Expand Down

0 comments on commit 5ccd3a9

Please sign in to comment.