OpenCoverage

o_time.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/o_time.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)-
3{-
4 struct tm *ts = -
5 ((void *)0)-
6 ;-
7 if (gmtime_r(timer, result) ==
gmtime_r(timer...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8010838 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8010838
8 ((void *)0)
gmtime_r(timer...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8010838 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8010838
9 )-
10 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
11 ((void *)0)
never executed: return ((void *)0) ;
0
12 ;
never executed: return ((void *)0) ;
0
13 ts = result;-
14 return
executed 8010838 times by 1 test: return ts;
Executed by:
  • libcrypto.so.1.1
ts;
executed 8010838 times by 1 test: return ts;
Executed by:
  • libcrypto.so.1.1
8010838
15}-
16static long date_to_julian(int y, int m, int d);-
17static void julian_to_date(long jd, int *y, int *m, int *d);-
18static int julian_adj(const struct tm *tm, int off_day, long offset_sec,-
19 long *pday, int *psec);-
20-
21int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)-
22{-
23 int time_sec, time_year, time_month, time_day;-
24 long time_jd;-
25-
26-
27 if (!julian_adj(tm, off_day, offset_sec, &time_jd, &time_sec)
!julian_adj(tm...jd, &time_sec)Description
TRUEevaluated 225 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4004477 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
225-4004477
28 return
executed 225 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 225 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
225
29-
30-
31-
32 julian_to_date(time_jd, &time_year, &time_month, &time_day);-
33-
34 if (time_year < 1900
time_year < 1900Description
TRUEevaluated 224 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4004253 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| time_year > 9999
time_year > 9999Description
TRUEevaluated 302 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4003951 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
224-4004253
35 return
executed 526 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 526 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
526
36-
37-
38-
39 tm->tm_year = time_year - 1900;-
40 tm->tm_mon = time_month - 1;-
41 tm->tm_mday = time_day;-
42-
43 tm->tm_hour = time_sec / 3600;-
44 tm->tm_min = (time_sec / 60) % 60;-
45 tm->tm_sec = time_sec % 60;-
46-
47 return
executed 4003951 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 4003951 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
4003951
48-
49}-
50-
51int OPENSSL_gmtime_diff(int *pday, int *psec,-
52 const struct tm *from, const struct tm *to)-
53{-
54 int from_sec, to_sec, diff_sec;-
55 long from_jd, to_jd, diff_day;-
56 if (!julian_adj(from, 0, 0, &from_jd, &from_sec)
!julian_adj(fr...jd, &from_sec)Description
TRUEnever evaluated
FALSEevaluated 4008425 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-4008425
57 return
never executed: return 0;
0;
never executed: return 0;
0
58 if (!julian_adj(to, 0, 0, &to_jd, &to_sec)
!julian_adj(to...o_jd, &to_sec)Description
TRUEnever evaluated
FALSEevaluated 4008425 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-4008425
59 return
never executed: return 0;
0;
never executed: return 0;
0
60 diff_day = to_jd - from_jd;-
61 diff_sec = to_sec - from_sec;-
62-
63 if (diff_day > 0
diff_day > 0Description
TRUEevaluated 1984741 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2023684 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& diff_sec < 0
diff_sec < 0Description
TRUEevaluated 1546905 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 437836 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
437836-2023684
64 diff_day--;-
65 diff_sec += (24 * 60 * 60);-
66 }
executed 1546905 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1546905
67 if (diff_day < 0
diff_day < 0Description
TRUEevaluated 1936844 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2071581 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& diff_sec > 0
diff_sec > 0Description
TRUEevaluated 435463 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1501381 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
435463-2071581
68 diff_day++;-
69 diff_sec -= (24 * 60 * 60);-
70 }
executed 435463 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
435463
71-
72 if (pday
pdayDescription
TRUEevaluated 4008425 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-4008425
73 *
executed 4008425 times by 1 test: *pday = (int)diff_day;
Executed by:
  • libcrypto.so.1.1
pday = (int)diff_day;
executed 4008425 times by 1 test: *pday = (int)diff_day;
Executed by:
  • libcrypto.so.1.1
4008425
74 if (psec
psecDescription
TRUEevaluated 4008425 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-4008425
75 *
executed 4008425 times by 1 test: *psec = diff_sec;
Executed by:
  • libcrypto.so.1.1
psec = diff_sec;
executed 4008425 times by 1 test: *psec = diff_sec;
Executed by:
  • libcrypto.so.1.1
4008425
76-
77 return
executed 4008425 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 4008425 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
4008425
78-
79}-
80-
81-
82static int julian_adj(const struct tm *tm, int off_day, long offset_sec,-
83 long *pday, int *psec)-
84{-
85 int offset_hms, offset_day;-
86 long time_jd;-
87 int time_year, time_month, time_day;-
88-
89 offset_day = offset_sec / (24 * 60 * 60);-
90-
91 offset_hms = offset_sec - (offset_day * (24 * 60 * 60));-
92 offset_day += off_day;-
93-
94 offset_hms += tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;-
95-
96 if (offset_hms >= (24 * 60 * 60)
offset_hms >= (24 * 60 * 60)Description
TRUEevaluated 1545110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10476442 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
1545110-10476442
97 offset_day++;-
98 offset_hms -= (24 * 60 * 60);-
99 }
executed 1545110 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else if (offset_hms < 0
offset_hms < 0Description
TRUEevaluated 435160 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10041282 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
435160-10041282
100 offset_day--;-
101 offset_hms += (24 * 60 * 60);-
102 }
executed 435160 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
435160
103-
104-
105-
106-
107-
108 time_year = tm->tm_year + 1900;-
109 time_month = tm->tm_mon + 1;-
110 time_day = tm->tm_mday;-
111-
112 time_jd = date_to_julian(time_year, time_month, time_day);-
113-
114-
115 time_jd += offset_day;-
116-
117 if (time_jd < 0
time_jd < 0Description
TRUEevaluated 225 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12021327 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
225-12021327
118 return
executed 225 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 225 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
225
119-
120 *pday = time_jd;-
121 *psec = offset_hms;-
122 return
executed 12021327 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 12021327 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
12021327
123}-
124-
125-
126-
127-
128static long date_to_julian(int y, int m, int d)-
129{-
130 return
executed 12021552 times by 1 test: return (1461 * (y + 4800 + (m - 14) / 12)) / 4 + (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 - (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 + d - 32075;
Executed by:
  • libcrypto.so.1.1
(1461 * (y + 4800 + (m - 14) / 12)) / 4 +
executed 12021552 times by 1 test: return (1461 * (y + 4800 + (m - 14) / 12)) / 4 + (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 - (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 + d - 32075;
Executed by:
  • libcrypto.so.1.1
12021552
131 (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 -
executed 12021552 times by 1 test: return (1461 * (y + 4800 + (m - 14) / 12)) / 4 + (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 - (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 + d - 32075;
Executed by:
  • libcrypto.so.1.1
12021552
132 (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 + d - 32075;
executed 12021552 times by 1 test: return (1461 * (y + 4800 + (m - 14) / 12)) / 4 + (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 - (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 + d - 32075;
Executed by:
  • libcrypto.so.1.1
12021552
133}-
134-
135static void julian_to_date(long jd, int *y, int *m, int *d)-
136{-
137 long L = jd + 68569;-
138 long n = (4 * L) / 146097;-
139 long i, j;-
140-
141 L = L - (146097 * n + 3) / 4;-
142 i = (4000 * (L + 1)) / 1461001;-
143 L = L - (1461 * i) / 4 + 31;-
144 j = (80 * L) / 2447;-
145 *d = L - (2447 * j) / 80;-
146 L = j / 11;-
147 *m = j + 2 - (12 * L);-
148 *y = 100 * (n - 49) + i + L;-
149}
executed 4004477 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4004477
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2