Coder Social home page Coder Social logo

Comments (10)

zma avatar zma commented on July 28, 2024

I pushed a quick fix. It is not perfect--the buffer for local time may be longer than the buffer.

But at least it avoids the warning messages.

$ gcc-8 -Wall example.c zlog.c -o example -lpthread
$ gcc-8 --version
gcc-8 (Ubuntu 8.3.0-6ubuntu1~18.04) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

from zlog.

pmembrey avatar pmembrey commented on July 28, 2024

Confirmed that it avoids the warning for me too. Would be good to look at a more robust fix for a future version maybe but this is already an improvement :)

from zlog.

pmembrey avatar pmembrey commented on July 28, 2024

Did some quick tests - looks good. Thanks for taking care of this so quickly! :)

from zlog.

zma avatar zma commented on July 28, 2024

Thanks for the confirmation.

So far, I would like to find some time to do some more revisions first to handle the cases when the strftime() returns 0 if the buffer is not large enough ( https://www.systutorials.com/docs/linux/man/3-strftime/ ) although it is rare. If strftime() fails, the library can fall back to the ! ZLOG_REAL_WORLD_TIME case.

from zlog.

jwaggy avatar jwaggy commented on July 28, 2024

Could you use ctime_r() for the datetime formatting which is guaranteed to be 26 bytes or less?

from zlog.

zma avatar zma commented on July 28, 2024

@jwaggy ctime_r() sounds a better solution. Would you like to send some pull request?

from zlog.

pmembrey avatar pmembrey commented on July 28, 2024

This was fixed in master as of 44c5d8a but current master fails to compile with the same error. Looks like a regression....

from zlog.

pmembrey avatar pmembrey commented on July 28, 2024

Looks like it was introduced in this commit: 93e66a8

from zlog.

zma avatar zma commented on July 28, 2024

I may take a little time and implement @jwaggy’s suggestion to fix this problem.

from zlog.

zma avatar zma commented on July 28, 2024

The warnings should now be taken care of.

from zlog.

Related Issues (2)

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.