Giter Club home page Giter Club logo

snore's People

Contributors

bitsmanent avatar bsprober avatar jpdoyle avatar vorboyvo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

snore's Issues

The `[0,INT_MAX)` time check allows NaN through

$ ./snore 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d
00d 00h 00m 00.000s

If you add printf("%f\n",tm); after https://github.com/clamiax/snore/blob/caad43cde564123b541df3cb2652df55937ac45f/snore.c#L118 you can observe that the number is NaN:

$ ./snore 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d
-nan
00d 00h 00m 00.000s

This ends up being accidentally safe because all comparisons involving NaN are false, so tm < endtm is false and the loop is never entered. However, if the loop is ever executed, this would invoke undefined behavior, as demonstrated if you run with ubsan on the branch https://github.com/jpdoyle/snore/tree/nan-unsafety:

$ ./snore 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d
-nan
snore.c:98:6: runtime error: store to null pointer of type 'char'

snore SIGSEGVs with long times

For example:

$ ./snore 26000d
fish: “./snore 26000d” terminated by signal SIGSEGV (Address boundary error)

I know the time is not very reasonable, but sleep handles it fine, and SIGSEGVs are never nice.

Support ‘snore inf’

sleep(1) supports the sleep inf syntax, which sleeps indefinitely. This should be supported by snore for two reasons:

  • sleep(1) compatibility, to make snore a drop-in replacement for sleep;
  • act as a stopwatch (do not print the time in descending order in this case).

In my opinion, snore without arguments should behave like snore inf, but I don't know if you are willing to change its behavior at this point.

Apparently, software is never "complete" :)

Tag releases

Hello @clamiax,

If you could tag releases it would help downstream packaging.

Thanks!

Suggestion: Add a progress bar

There's quite a bit on unused space to the right of the counter. Maybe it could be filled with an ASCII progress bar?

(Also, is it possible to hide the days and hours etc. when they aren't used for a counter? They make it more difficult to visually grep what's going on.)

Does not compile on OS X

While compiling on OS X (Darwin Kernel Version 15.6.0, RELEASE_X86_64 x86_64), I get the following error:

snore.c:110:16: error: use of undeclared identifier 'CLOCK_REALTIME'
clock_gettime(CLOCK_REALTIME, &start);

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.