| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/o_time.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | struct 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) ==
| 0-8010838 | ||||||||||||
| 8 | ((void *)0)
| 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: ts;return ts;Executed by:
executed 8010838 times by 1 test: return ts;Executed by:
| 8010838 | ||||||||||||
| 15 | } | - | ||||||||||||
| 16 | static long date_to_julian(int y, int m, int d); | - | ||||||||||||
| 17 | static void julian_to_date(long jd, int *y, int *m, int *d); | - | ||||||||||||
| 18 | static int julian_adj(const struct tm *tm, int off_day, long offset_sec, | - | ||||||||||||
| 19 | long *pday, int *psec); | - | ||||||||||||
| 20 | - | |||||||||||||
| 21 | int 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)
| 225-4004477 | ||||||||||||
| 28 | return executed 225 times by 1 test: 0;return 0;Executed by:
executed 225 times by 1 test: return 0;Executed by:
| 225 | ||||||||||||
| 29 | - | |||||||||||||
| 30 | - | |||||||||||||
| 31 | - | |||||||||||||
| 32 | julian_to_date(time_jd, &time_year, &time_month, &time_day); | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | if (time_year < 1900
| 224-4004253 | ||||||||||||
| 35 | return executed 526 times by 1 test: 0;return 0;Executed by:
executed 526 times by 1 test: return 0;Executed by:
| 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: 1;return 1;Executed by:
executed 4003951 times by 1 test: return 1;Executed by:
| 4003951 | ||||||||||||
| 48 | - | |||||||||||||
| 49 | } | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | int 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)
| 0-4008425 | ||||||||||||
| 57 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 58 | if (!julian_adj(to, 0, 0, &to_jd, &to_sec)
| 0-4008425 | ||||||||||||
| 59 | return never executed: 0;return 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
| 437836-2023684 | ||||||||||||
| 64 | diff_day--; | - | ||||||||||||
| 65 | diff_sec += (24 * 60 * 60); | - | ||||||||||||
| 66 | } executed 1546905 times by 1 test: end of blockExecuted by:
| 1546905 | ||||||||||||
| 67 | if (diff_day < 0
| 435463-2071581 | ||||||||||||
| 68 | diff_day++; | - | ||||||||||||
| 69 | diff_sec -= (24 * 60 * 60); | - | ||||||||||||
| 70 | } executed 435463 times by 1 test: end of blockExecuted by:
| 435463 | ||||||||||||
| 71 | - | |||||||||||||
| 72 | if (pday
| 0-4008425 | ||||||||||||
| 73 | * executed 4008425 times by 1 test: pday = (int)diff_day;*pday = (int)diff_day;Executed by:
executed 4008425 times by 1 test: *pday = (int)diff_day;Executed by:
| 4008425 | ||||||||||||
| 74 | if (psec
| 0-4008425 | ||||||||||||
| 75 | * executed 4008425 times by 1 test: psec = diff_sec;*psec = diff_sec;Executed by:
executed 4008425 times by 1 test: *psec = diff_sec;Executed by:
| 4008425 | ||||||||||||
| 76 | - | |||||||||||||
| 77 | return executed 4008425 times by 1 test: 1;return 1;Executed by:
executed 4008425 times by 1 test: return 1;Executed by:
| 4008425 | ||||||||||||
| 78 | - | |||||||||||||
| 79 | } | - | ||||||||||||
| 80 | - | |||||||||||||
| 81 | - | |||||||||||||
| 82 | static 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)
| 1545110-10476442 | ||||||||||||
| 97 | offset_day++; | - | ||||||||||||
| 98 | offset_hms -= (24 * 60 * 60); | - | ||||||||||||
| 99 | } executed 1545110 times by 1 test: else if (offset_hms < 0end of blockExecuted by:
| 435160-10041282 | ||||||||||||
| 100 | offset_day--; | - | ||||||||||||
| 101 | offset_hms += (24 * 60 * 60); | - | ||||||||||||
| 102 | } executed 435160 times by 1 test: end of blockExecuted by:
| 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
| 225-12021327 | ||||||||||||
| 118 | return executed 225 times by 1 test: 0;return 0;Executed by:
executed 225 times by 1 test: return 0;Executed by:
| 225 | ||||||||||||
| 119 | - | |||||||||||||
| 120 | *pday = time_jd; | - | ||||||||||||
| 121 | *psec = offset_hms; | - | ||||||||||||
| 122 | return executed 12021327 times by 1 test: 1;return 1;Executed by:
executed 12021327 times by 1 test: return 1;Executed by:
| 12021327 | ||||||||||||
| 123 | } | - | ||||||||||||
| 124 | - | |||||||||||||
| 125 | - | |||||||||||||
| 126 | - | |||||||||||||
| 127 | - | |||||||||||||
| 128 | static long date_to_julian(int y, int m, int d) | - | ||||||||||||
| 129 | { | - | ||||||||||||
| 130 | return executed 12021552 times by 1 test: (1461 * (y + 4800 + (m - 14) / 12)) / 4 +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:
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:
| 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:
| 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:
| 12021552 | ||||||||||||
| 133 | } | - | ||||||||||||
| 134 | - | |||||||||||||
| 135 | static 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 blockExecuted by:
| 4004477 | ||||||||||||
| Switch to Source code | Preprocessed file |