================ @@ -0,0 +1,75 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// This file contains the implementation of strcpy_s. +/// +//===----------------------------------------------------------------------===// + +#define __STDC_WANT_LIB_EXT1__ 1 +#include "hdr/stdint_proxy.h" +#undef __STDC_WANT_LIB_EXT1__ +#include "hdr/types/constraint_handler_t.h" +#include "hdr/types/errno_t.h" +#include "hdr/types/rsize_t.h" +#include "src/__support/common.h" +#include "src/__support/constraint_handler.h" +#include "src/__support/macros/config.h" +#include "src/string/memory_utils/inline_memcpy.h" +#include "src/string/strcpy_s.h" +#include "src/string/string_utils.h" +#include "src/string/strnlen_s.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(errno_t, strcpy_s, + (char *__restrict s1, rsize_t s1max, + const char *__restrict s2)) { + const char *constraint_violation_msg = 0; + size_t count; + + if (s1 == 0) { ---------------- kaladron wrote:
I think this if chain might be better done in a function that returns cpp::expected or something similar. Then instead of a series of else/if you could have if (..) return ""; And make it clear that there you're not expecting multiple of these to be true and are just matching ont he first. https://github.com/llvm/llvm-project/pull/197709 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
