1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
Description: Fix incorrect pointer type and change to time_t
Altered pointer comparison in dlocaltime function to properly check for NULL.
.
Replaced the incorrect check `clock == (long*) 0` with `!clock` to ensure the
pointer validation is done safely.
.
Changed the return value to `NULL` instead of an invalid cast to
`(struct tws*) 0` to follow proper C conventions and improve clarity.
.
Ensures better readability and prevents potential pointer-related type errors.
Bug-Debian: https://bugs.debian.org/1065972
Author: Leandro Cunha <leandrocunha016@gmail.com>
---
tws.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tws.c b/tws.c
index cbafeb2..4e601d5 100644
--- a/tws.c
+++ b/tws.c
@@ -37,17 +37,16 @@ extern long timezone;
#include <sys/timeb.h>
#endif /*SYS5*/
-extern long time();
struct tm* localtime();
struct tws *dtwstime()
{
- long clock = 0;
+ time_t clock = 0;
char *phoontime = getenv( "PHOONTIME" );
if( phoontime )
{
- clock = strtol( phoontime, 0, 0 );
+ clock = strtol( phoontime, NULL, 0 );
}
if( !clock )
@@ -57,7 +56,7 @@ struct tws *dtwstime()
return dlocaltime( &clock );
}
-struct tws* dlocaltime( long* clock )
+struct tws* dlocaltime( const time_t *clock )
{
register struct tm* tm;
#ifndef SYS5
@@ -65,8 +64,10 @@ register struct tm* tm;
#endif /*not SYS5*/
static struct tws tw;
- if ( clock == (long*) 0 )
- return (struct tws*) 0;
+ if ( !clock )
+ {
+ return NULL;
+ }
tw.tw_flags = TW_NULL;
tm = localtime( clock );
|