From 675e2feb8c852e061140f3e4929b0e954230084c Mon Sep 17 00:00:00 2001 From: Oliver Lehmann Date: Sat, 2 Jul 2016 10:46:38 +0200 Subject: [PATCH] fix case when no timer is installed at all --- .../src/cmd/standalone/sa.timer/kernel/timer.c | 10 ++++++---- .../standalone/sa.timer/standalone/sa.timer.c | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) mode change 100644 => 100755 WEGA/src/cmd/standalone/sa.timer/kernel/timer.c mode change 100644 => 100755 WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c diff --git a/WEGA/src/cmd/standalone/sa.timer/kernel/timer.c b/WEGA/src/cmd/standalone/sa.timer/kernel/timer.c old mode 100644 new mode 100755 index e2f1bc0..f39ddb5 --- a/WEGA/src/cmd/standalone/sa.timer/kernel/timer.c +++ b/WEGA/src/cmd/standalone/sa.timer/kernel/timer.c @@ -25,7 +25,7 @@ * * $Id: timer.c,v 1.6 2009/08/22 15:45:33 olivleh1 Exp $ */ - + #include #include "rtc72421.h" @@ -38,13 +38,14 @@ gettime() register long time = 0; register i; struct clock_type *t; - int a,b; + int a,b; int clock_min_year; int clock_max_year; int (*clock_finit)(); long (*clock_fget)(); void (*clock_fset)(); void (*clock_fstart)(); + int clock_found = 0; t = clock_devs; @@ -53,6 +54,7 @@ gettime() b = t->clock_det_str; if(a == b) { printf("%s found\n",t->clock_name); + clock_found = 1; clock_finit = t->clock_finit; clock_fget = t->clock_fget; clock_fset = t->clock_fset; @@ -64,8 +66,8 @@ gettime() } /* function pointer assigned? => RTC found?*/ - if (clock_finit > 0) { - clock_finit(); + if (clock_found == 1) { + clock_finit(); time = clock_fget(); } diff --git a/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c b/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c old mode 100644 new mode 100755 index a950269..8c8e500 --- a/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c +++ b/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c @@ -25,7 +25,7 @@ * * $Id: sa.timer.c,v 1.12 2009/08/16 14:52:52 olivleh1 Exp $ */ - + #include "time.h" #include "u130.h" @@ -49,7 +49,8 @@ main() register long time; register i; struct clock_type *t; - int a,b; + int a,b; + int clock_found = 0; t = clock_devs; @@ -58,6 +59,7 @@ main() b = t->clock_det_str; if(a == b) { printf("%s found\n",t->clock_name); + clock_found = 1; clock_finit = t->clock_finit; clock_fget = t->clock_fget; clock_fset = t->clock_fset; @@ -69,13 +71,13 @@ main() } /* function pointer assigned? => RTC found?*/ - if (clock_finit > 0) { - clock_finit(); + if (clock_found == 1) { + clock_finit(); time = clock_fget(); - outtime(time); - settimer(time); + outtime(time); + settimer(time); time = clock_fget(); - outtime(time); + outtime(time); exit(0); } else { printf("Timer not available\n"); @@ -149,7 +151,7 @@ loop1: if (tm_mon<0 || tm_mon>11 || tm_mday<1 || tm_mday>31 || tm_yearclock_max_year) goto loop1; - + loop2: printf("Enter new Time in GMT (HH:MM) : "); gets(estring, sizeof estring);