@@ -94,7 +94,7 @@ struct tlog {
94
94
};
95
95
96
96
struct tlog_segment_log_head {
97
- struct tlog_info info ;
97
+ struct tlog_loginfo info ;
98
98
unsigned short len ;
99
99
char data [0 ];
100
100
} __attribute__((packed ));
@@ -117,7 +117,7 @@ struct count_log {
117
117
};
118
118
119
119
struct tlog_info_inter {
120
- struct tlog_info info ;
120
+ struct tlog_loginfo info ;
121
121
void * userptr ;
122
122
};
123
123
@@ -203,8 +203,8 @@ static int _tlog_mkdir(const char *path)
203
203
204
204
static struct tm * _tlog_localtime (time_t * timep , struct tm * tm )
205
205
{
206
- static time_t last_time = { 0 } ;
207
- static struct tm last_tm = { 0 } ;
206
+ static time_t last_time ;
207
+ static struct tm last_tm ;
208
208
209
209
/* localtime_r has a global timezone lock, it's about 8 times slower than gmtime
210
210
* this code is used to speed up localtime_r call.
@@ -297,11 +297,14 @@ void *tlog_get_private(tlog_log *log)
297
297
return log -> private_data ;
298
298
}
299
299
300
- static int _tlog_format (char * buff , int maxlen , struct tlog_info * info , void * userptr , const char * format , va_list ap )
300
+ static int _tlog_format (char * buff , int maxlen , struct tlog_loginfo * info , void * userptr , const char * format , va_list ap )
301
301
{
302
302
int len = 0 ;
303
303
int total_len = 0 ;
304
304
struct tlog_time * tm = & info -> time ;
305
+ void * unused __attribute__ ((unused ));
306
+
307
+ unused = userptr ;
305
308
306
309
if (tlog .root -> multi_log ) {
307
310
/* format prefix */
@@ -388,6 +391,9 @@ static int _tlog_print_buffer(char *buff, int maxlen, void *userptr, const char
388
391
{
389
392
int len ;
390
393
int total_len = 0 ;
394
+ void * unused __attribute__ ((unused ));
395
+
396
+ unused = userptr ;
391
397
392
398
/* format log message */
393
399
len = vsnprintf (buff , maxlen , format , ap );
@@ -550,8 +556,9 @@ int tlog_printf(struct tlog_log *log, const char *format, ...)
550
556
static int _tlog_early_print (const char * format , va_list ap )
551
557
{
552
558
char log_buf [TLOG_MAX_LINE_LEN ];
553
- int len = 0 ;
554
- int out_len = 0 ;
559
+ size_t len = 0 ;
560
+ size_t out_len = 0 ;
561
+ int unused __attribute__ ((unused ));
555
562
556
563
if (tlog_disable_early_print ) {
557
564
return 0 ;
@@ -565,9 +572,9 @@ static int _tlog_early_print(const char *format, va_list ap)
565
572
out_len = sizeof (log_buf );
566
573
}
567
574
568
- write (STDOUT_FILENO , log_buf , out_len );
575
+ unused = write (STDOUT_FILENO , log_buf , out_len );
569
576
if (log_buf [out_len - 1 ] != '\n' ) {
570
- write (STDOUT_FILENO , "\n" , 1 );
577
+ unused = write (STDOUT_FILENO , "\n" , 1 );
571
578
}
572
579
573
580
return len ;
@@ -650,6 +657,7 @@ static int _tlog_list_dir(const char *path, list_callback callback, void *userpt
650
657
DIR * dir = NULL ;
651
658
struct dirent * ent ;
652
659
int ret = 0 ;
660
+ const char * unused __attribute__ ((unused )) = path ;
653
661
654
662
dir = opendir (path );
655
663
if (dir == NULL ) {
@@ -682,6 +690,7 @@ static int _tlog_count_log_callback(const char *path, struct dirent *entry, void
682
690
struct count_log * count_log = (struct count_log * )userptr ;
683
691
struct tlog_log * log = count_log -> log ;
684
692
char logname [TLOG_LOG_NAME_LEN * 2 ];
693
+ const char * unused __attribute__ ((unused )) = path ;
685
694
686
695
if (strstr (entry -> d_name , log -> suffix ) == NULL ) {
687
696
return 0 ;
@@ -1008,14 +1017,15 @@ static int _tlog_archive_log(struct tlog_log *log)
1008
1017
static int _tlog_write (struct tlog_log * log , const char * buff , int bufflen )
1009
1018
{
1010
1019
int len ;
1020
+ int unused __attribute__ ((unused ));
1011
1021
1012
1022
if (bufflen <= 0 ) {
1013
1023
return 0 ;
1014
1024
}
1015
1025
1016
1026
/* output log to screen */
1017
1027
if (log -> logscreen ) {
1018
- write (STDOUT_FILENO , buff , bufflen );
1028
+ unused = write (STDOUT_FILENO , buff , bufflen );
1019
1029
}
1020
1030
1021
1031
/* if log file size exceeds threshold, start to compress */
@@ -1027,7 +1037,7 @@ static int _tlog_write(struct tlog_log *log, const char *buff, int bufflen)
1027
1037
if (log -> filesize < lseek (log -> fd , 0 , SEEK_END ) && log -> multi_log == 0 ) {
1028
1038
const char * msg = "[Auto enable multi-process write mode, log may be lost, please enable multi-process write mode manually]\n" ;
1029
1039
log -> multi_log = 1 ;
1030
- write (log -> fd , msg , strlen (msg ));
1040
+ unused = write (log -> fd , msg , strlen (msg ));
1031
1041
}
1032
1042
close (log -> fd );
1033
1043
log -> fd = -1 ;
@@ -1326,7 +1336,10 @@ static void *_tlog_work(void *arg)
1326
1336
int log_dropped = 0 ;
1327
1337
struct tlog_log * log = NULL ;
1328
1338
struct tlog_log * loop_log = NULL ;
1339
+ void * unused __attribute__ ((unused ));
1329
1340
1341
+ unused = arg ;
1342
+
1330
1343
while (1 ) {
1331
1344
log_len = 0 ;
1332
1345
log_extlen = 0 ;
0 commit comments