From 56bd595396874d6cfdbc4e0d6d4b9b762f5b8c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sun, 6 May 2018 03:45:56 +0200 Subject: [PATCH] Modernize. --- include/cryb/memcpy_s.h | 10 +++++++++- include/cryb/memset_s.h | 2 +- lib/core/cryb_memcpy_s.c | 4 ++-- lib/core/cryb_memset_s.c | 4 ++-- t/t_memcpy_s.c | 12 +++++++----- t/t_memset_s.c | 2 +- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/include/cryb/memcpy_s.h b/include/cryb/memcpy_s.h index 6fa6a34..5fd5c25 100644 --- a/include/cryb/memcpy_s.h +++ b/include/cryb/memcpy_s.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 The University of Oslo + * Copyright (c) 2015-2018 The University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,6 +30,12 @@ #ifndef CRYB_MEMCPY_S_H_INCLUDED #define CRYB_MEMCPY_S_H_INCLUDED +#ifndef CRYB_TO +#include +#endif + +CRYB_BEGIN + int cryb_memcpy_s(void *, size_t, const void *, size_t); #if !HAVE_MEMCPY_S @@ -37,4 +43,6 @@ int cryb_memcpy_s(void *, size_t, const void *, size_t); #define memcpy_s(arg, ...) cryb_memcpy_s(arg, __VA_ARGS__) #endif +CRYB_END + #endif diff --git a/include/cryb/memset_s.h b/include/cryb/memset_s.h index 9e86886..cf71781 100644 --- a/include/cryb/memset_s.h +++ b/include/cryb/memset_s.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 The University of Oslo + * Copyright (c) 2015-2018 The University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/lib/core/cryb_memcpy_s.c b/lib/core/cryb_memcpy_s.c index 3ecc7b6..550305a 100644 --- a/lib/core/cryb_memcpy_s.c +++ b/lib/core/cryb_memcpy_s.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Dag-Erling Smørgrav + * Copyright (c) 2015-2018 The University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -72,6 +72,6 @@ CRYB_RESTORE_COVERAGE return (EINVAL); } for (i = 0; i < dsz && i < n; ++i) - ((volatile unsigned char *)d)[i] = ((unsigned char *)s)[i]; + ((volatile uint8_t *)d)[i] = ((const uint8_t *)s)[i]; return (0); } diff --git a/lib/core/cryb_memset_s.c b/lib/core/cryb_memset_s.c index 61d2fe2..6730007 100644 --- a/lib/core/cryb_memset_s.c +++ b/lib/core/cryb_memset_s.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 The University of Oslo + * Copyright (c) 2015-2018 The University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,7 +55,7 @@ CRYB_DISABLE_COVERAGE return (ERANGE); CRYB_RESTORE_COVERAGE for (i = 0; i < n && i < dsz; ++i) - ((volatile unsigned char *)d)[i] = (unsigned char)ch; + ((volatile uint8_t *)d)[i] = (uint8_t)ch; if (n > dsz) return (EOVERFLOW); return (0); diff --git a/t/t_memcpy_s.c b/t/t_memcpy_s.c index 057d2ff..76b45be 100644 --- a/t/t_memcpy_s.c +++ b/t/t_memcpy_s.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Dag-Erling Smørgrav + * Copyright (c) 2015-2018 The University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -289,16 +289,18 @@ t_prepare(int argc, char *argv[]) t_add_test(t_memcpy_s_null_d, NULL, "null destination"); n = sizeof t_plain_cases / sizeof t_plain_cases[0]; for (i = 0; i < n; ++i) - t_add_test(t_memcpy_s, &t_plain_cases[i], + t_add_test(t_memcpy_s, &t_plain_cases[i], "%s", t_plain_cases[i].desc); n = sizeof t_overlap_cases / sizeof t_overlap_cases[0]; for (i = 0; i < n; ++i) - t_add_test(t_memcpy_s_overlap, &t_overlap_cases[i], + t_add_test(t_memcpy_s_overlap, &t_overlap_cases[i], "%s", t_overlap_cases[i].desc); return (0); } -void -t_cleanup(void) +int +main(int argc, char *argv[]) { + + t_main(t_prepare, NULL, argc, argv); } diff --git a/t/t_memset_s.c b/t/t_memset_s.c index 25ff0fa..1c935c8 100644 --- a/t/t_memset_s.c +++ b/t/t_memset_s.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 The University of Oslo + * Copyright (c) 2015-2018 The University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without