X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=time.c;h=83231c895020245d72cea40cd34cae03e9951a29;hp=d6e070809e527fba5437f59e0fe7976893432b9e;hb=60216e4058f4ecc24467df577e51cb2bd66508b0;hpb=8a8cd0f5bb40dcfad68608193e8c57decd90b25e diff --git a/time.c b/time.c index d6e07080..83231c89 100644 --- a/time.c +++ b/time.c @@ -106,14 +106,20 @@ void tv_scale(const unsigned long mult, const struct timeval *tv, /** * compute fraction of given struct timeval * - * \param divider the integer value to divide by + * \param divisor the integer value to divide by * \param tv the timevalue to divide * \param result holds (1 / mult) * tv upon return */ void tv_divide(const unsigned long divisor, const struct timeval *tv, struct timeval *result) { - long unsigned q = tv->tv_usec / divisor; + long unsigned q; + + if (!divisor) { + PARA_EMERG_LOG("%s\n", "division by zero"); + exit(EXIT_FAILURE); + } + q = tv->tv_usec / divisor; result->tv_sec = tv->tv_sec / divisor; result->tv_usec = (tv->tv_sec - result->tv_sec * divisor) * 1000 * 1000 / divisor;