Giter Site home page Giter Site logo

Comments (6)

rurban avatar rurban commented on July 30, 2024 1

memset_s documents the different behavior if under C11:
Since C11 smax=0 is allowed, before it fails with ESZEROL.
So we'll have to check for C11 (added a compile-time configure probe)

On C11 allow smax/n=0, before keep the old behavior: ESZEROL. Good?

from safeclib.

rurban avatar rurban commented on July 30, 2024

I don't care that much about the perf. issue, but about convenience and conformance, analog to free(NULL) (supporting your point).

I'll check how prior art (MSVC) does it, when the standard does not mention it.
And this code was in production at Cisco since 2008, so changing might be disruptive.

Using memcpy_s over memcpy might suggest erroring on a 0 length argument. i.e. a security feature. (keeping it asis)

from safeclib.

rurban avatar rurban commented on July 30, 2024

In MSVC and wine/ReactOS smax=0 is valid: https://msdn.microsoft.com/en-us/library/wes2t00f.aspx

from safeclib.

jeremyhannon avatar jeremyhannon commented on July 30, 2024

fixed in d453998.

from safeclib.

jeremyhannon avatar jeremyhannon commented on July 30, 2024

@rurban since you now have a HAVE_C11 and WANT_C11 I was a little confused about the difference until I researched it. So I'd suggest renaming WANT_C11 to WANT_C11_ANNEXK or WANT_C11_LIB_EXT1 to make it clearer that you're wanting a subset/extension instead of wanting to use the C11 base standard.

But at that point why not just use #if __STDC_WANT_LIB_EXT1__ >= 1 everywhere so you're not using a custom symbol?

from safeclib.

rurban avatar rurban commented on July 30, 2024

I admit it's confusing at the first glance.
But I'd rather stay with the short form. It's only used in a few places where the actual upstream code is usable (memset_s on darwin).

WANT_C11 means #if __STDC_WANT_LIB_EXT1__ >= 1, yes. But we would need to use the long form #if defined(__STDC_WANT_LIB_EXT1__) && (__STDC_WANT_LIB_EXT1__ >= 1)

The idea of safec is to implement C11 fully. Other's say they do, but they don't. Having this discrepancy, I think it's easier to make it clear with this short name.
I don't want to emphasis it as extension, safe functions must be the default. Microsoft even warns all users to switch over to the safe variants.

from safeclib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.