34
34
#if !defined _Noreturn && \
35
35
(!defined(__STDC_VERSION__ ) || __STDC_VERSION__ < 201112 )
36
36
#if 2 < __GNUC__ + (8 <= __GNUC_MINOR__ )
37
- #define _Noreturn __attribute__((__noreturn__))
37
+ #define _Noreturn __attribute__ ((__noreturn__))
38
38
#else
39
39
#define _Noreturn
40
40
#endif
@@ -181,7 +181,7 @@ struct ttinfo { /* time type information */
181
181
};
182
182
183
183
struct lsinfo { /* leap second information */
184
- int64_t ls_trans ; /* transition time */
184
+ int64_t ls_trans ; /* transition time */
185
185
int_fast64_t ls_corr ; /* correction to apply */
186
186
};
187
187
@@ -241,16 +241,22 @@ static int64_t
241
241
normalize_overflow (int64_t * tensptr , int64_t * unitsptr , int64_t base );
242
242
static int64_t
243
243
time1 (struct bson_tm * tmp ,
244
- struct bson_tm * (* funcp ) (const int64_t * , int_fast32_t , struct bson_tm * ),
244
+ struct bson_tm * (* funcp ) (const int64_t * ,
245
+ int_fast32_t ,
246
+ struct bson_tm * ),
245
247
int_fast32_t offset );
246
248
static int64_t
247
249
time2 (struct bson_tm * tmp ,
248
- struct bson_tm * (* funcp ) (const int64_t * , int_fast32_t , struct bson_tm * ),
250
+ struct bson_tm * (* funcp ) (const int64_t * ,
251
+ int_fast32_t ,
252
+ struct bson_tm * ),
249
253
int_fast32_t offset ,
250
254
int64_t * okayp );
251
255
static int64_t
252
256
time2sub (struct bson_tm * tmp ,
253
- struct bson_tm * (* funcp ) (const int64_t * , int_fast32_t , struct bson_tm * ),
257
+ struct bson_tm * (* funcp ) (const int64_t * ,
258
+ int_fast32_t ,
259
+ struct bson_tm * ),
254
260
int_fast32_t offset ,
255
261
int64_t * okayp ,
256
262
int64_t do_norm_secs );
@@ -434,8 +440,11 @@ timesub (const int64_t *const timep,
434
440
*/
435
441
tmp -> tm_sec = (int64_t ) (rem % SECSPERMIN ) + hit ;
436
442
ip = mon_lengths [isleap (y )];
437
- for (tmp -> tm_mon = 0 ; idays >= ip [tmp -> tm_mon ]; ++ (tmp -> tm_mon ))
438
- idays -= ip [tmp -> tm_mon ];
443
+ tmp -> tm_mon = 0 ;
444
+ while (idays >= ip [tmp -> tm_mon ]) {
445
+ idays -= ip [tmp -> tm_mon ++ ];
446
+ BSON_ASSERT (tmp -> tm_mon < MONSPERYEAR );
447
+ }
439
448
tmp -> tm_mday = (int64_t ) (idays + 1 );
440
449
tmp -> tm_isdst = 0 ;
441
450
#ifdef TM_GMTOFF
@@ -490,7 +499,9 @@ increment_overflow32 (int_fast32_t *const lp, int64_t const m)
490
499
}
491
500
492
501
static int64_t
493
- normalize_overflow (int64_t * const tensptr , int64_t * const unitsptr , const int64_t base )
502
+ normalize_overflow (int64_t * const tensptr ,
503
+ int64_t * const unitsptr ,
504
+ const int64_t base )
494
505
{
495
506
register int64_t tensdelta ;
496
507
@@ -531,7 +542,9 @@ tmcomp (register const struct bson_tm *const atmp,
531
542
532
543
static int64_t
533
544
time2sub (struct bson_tm * const tmp ,
534
- struct bson_tm * (* const funcp ) (const int64_t * , int_fast32_t , struct bson_tm * ),
545
+ struct bson_tm * (* const funcp ) (const int64_t * ,
546
+ int_fast32_t ,
547
+ struct bson_tm * ),
535
548
const int_fast32_t offset ,
536
549
int64_t * const okayp ,
537
550
const int64_t do_norm_secs )
@@ -700,7 +713,9 @@ time2sub (struct bson_tm *const tmp,
700
713
701
714
static int64_t
702
715
time2 (struct bson_tm * const tmp ,
703
- struct bson_tm * (* const funcp ) (const int64_t * , int_fast32_t , struct bson_tm * ),
716
+ struct bson_tm * (* const funcp ) (const int64_t * ,
717
+ int_fast32_t ,
718
+ struct bson_tm * ),
704
719
const int_fast32_t offset ,
705
720
int64_t * const okayp )
706
721
{
@@ -717,7 +732,9 @@ time2 (struct bson_tm *const tmp,
717
732
718
733
static int64_t
719
734
time1 (struct bson_tm * const tmp ,
720
- struct bson_tm * (* const funcp ) (const int64_t * , int_fast32_t , struct bson_tm * ),
735
+ struct bson_tm * (* const funcp ) (const int64_t * ,
736
+ int_fast32_t ,
737
+ struct bson_tm * ),
721
738
const int_fast32_t offset )
722
739
{
723
740
register int64_t t ;
@@ -792,4 +809,3 @@ _bson_timegm (struct bson_tm *const tmp)
792
809
tmp -> tm_isdst = 0 ;
793
810
return time1 (tmp , gmtsub , 0L );
794
811
}
795
-
0 commit comments