From 1e4eb5c154d935bc849210e205712622b8af749d Mon Sep 17 00:00:00 2001 From: Yu Qing Date: Thu, 10 Aug 2017 16:15:36 +0800 Subject: [PATCH] replace print format OFF_PRINTF_FORMAT to PRId64 --- HISTORY | 1 + storage/storage_service.c | 53 ++++++++++++++++++++------------------- storage/storage_sync.c | 5 ++-- tracker/tracker_service.c | 4 +-- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/HISTORY b/HISTORY index a18751c..1a8deab 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,7 @@ Version 5.12 2017-08-10 * code refine for rare case + * replace print format OFF_PRINTF_FORMAT to PRId64 Version 5.11 2017-05-26 * bug fixed: file_offset has no effect when use trunk file diff --git a/storage/storage_service.c b/storage/storage_service.c index 8368a58..e4a7a6d 100644 --- a/storage/storage_service.c +++ b/storage/storage_service.c @@ -4917,9 +4917,9 @@ static int storage_modify_file(struct fast_task_info *pTask) { logError("file: "__FILE__", line: %d, " \ "client ip: %s, file offset: %"PRId64 \ - " is invalid, which > appender file size: " \ - OFF_PRINTF_FORMAT, __LINE__, pTask->client_ip, \ - file_offset, stat_buf.st_size); + " is invalid, which > appender file size: %" \ + PRId64, __LINE__, pTask->client_ip, \ + file_offset, (int64_t)stat_buf.st_size); return EINVAL; } @@ -5097,10 +5097,10 @@ static int storage_do_truncate_file(struct fast_task_info *pTask) { logWarning("file: "__FILE__", line: %d, " \ "client ip: %s, truncated file size: " \ - "%"PRId64" == appender file size: " \ - OFF_PRINTF_FORMAT", skip truncate file", \ + "%"PRId64" == appender file size: %" \ + PRId64", skip truncate file", \ __LINE__, pTask->client_ip, \ - remain_bytes, stat_buf.st_size); + remain_bytes, (int64_t)stat_buf.st_size); return 0; } if (remain_bytes > stat_buf.st_size) @@ -5108,9 +5108,9 @@ static int storage_do_truncate_file(struct fast_task_info *pTask) logError("file: "__FILE__", line: %d, " \ "client ip: %s, truncated file size: " \ "%"PRId64" is invalid, " \ - "which > appender file size: " \ - OFF_PRINTF_FORMAT, __LINE__, pTask->client_ip, \ - remain_bytes, stat_buf.st_size); + "which > appender file size: %" \ + PRId64, __LINE__, pTask->client_ip, \ + remain_bytes, (int64_t)stat_buf.st_size); return EINVAL; } @@ -5554,11 +5554,11 @@ static int storage_sync_copy_file(struct fast_task_info *pTask, \ { logWarning("file: "__FILE__", line: %d, " \ "client ip: %s, logic file %s, " \ - "my file size: "OFF_PRINTF_FORMAT \ + "my file size: %"PRId64\ " != src file size: %"PRId64 \ ", will be overwrited", __LINE__, \ pTask->client_ip, filename, \ - stat_buf.st_size, file_bytes); + (int64_t)stat_buf.st_size, file_bytes); } else { @@ -5858,20 +5858,21 @@ static int storage_sync_append_file(struct fast_task_info *pTask) if (stat_buf.st_size >= start_offset + append_bytes) { logDebug("file: "__FILE__", line: %d, " \ - "client ip: %s, file %s, my file size: " \ - OFF_PRINTF_FORMAT" >= src file size: " \ + "client ip: %s, file %s, my file size: %" \ + PRId64" >= src file size: " \ "%"PRId64", do not append", \ __LINE__, pTask->client_ip, pFileContext->filename, \ - stat_buf.st_size, start_offset + append_bytes); + (int64_t)stat_buf.st_size, + start_offset + append_bytes); } else { logWarning("file: "__FILE__", line: %d, " \ - "client ip: %s, file %s, my file size: " \ - OFF_PRINTF_FORMAT" > %"PRId64 \ + "client ip: %s, file %s, my file size: %" \ + PRId64" > %"PRId64 \ ", but < %"PRId64", need be resynced", \ __LINE__, pTask->client_ip, pFileContext->filename, \ - stat_buf.st_size, start_offset, \ + (int64_t)stat_buf.st_size, start_offset, \ start_offset + append_bytes); } @@ -5881,11 +5882,11 @@ static int storage_sync_append_file(struct fast_task_info *pTask) else //stat_buf.st_size < start_offset { logWarning("file: "__FILE__", line: %d, " \ - "client ip: %s, file %s, my file size: " \ - OFF_PRINTF_FORMAT" < start offset " \ + "client ip: %s, file %s, my file size: %" \ + PRId64" < start offset " \ "%"PRId64", need to resync this file!", \ __LINE__, pTask->client_ip, pFileContext->filename, \ - stat_buf.st_size, start_offset); + (int64_t)stat_buf.st_size, start_offset); need_write_file = false; } @@ -6079,11 +6080,11 @@ static int storage_sync_modify_file(struct fast_task_info *pTask) else if (stat_buf.st_size < start_offset) { logWarning("file: "__FILE__", line: %d, " \ - "client ip: %s, file %s, my file size: " \ - OFF_PRINTF_FORMAT" < start offset " \ + "client ip: %s, file %s, my file size: %" \ + PRId64" < start offset " \ "%"PRId64", need to resync this file!", \ __LINE__, pTask->client_ip, pFileContext->filename, \ - stat_buf.st_size, start_offset); + (int64_t)stat_buf.st_size, start_offset); need_write_file = false; } else @@ -6278,11 +6279,11 @@ static int storage_sync_truncate_file(struct fast_task_info *pTask) if (stat_buf.st_size != old_file_size) { logWarning("file: "__FILE__", line: %d, " \ - "client ip: %s, file %s, my file size: " \ - OFF_PRINTF_FORMAT" != before truncated size: " \ + "client ip: %s, file %s, my file size: %" \ + PRId64" != before truncated size: " \ "%"PRId64", skip!", __LINE__, \ pTask->client_ip, pFileContext->filename, \ - stat_buf.st_size, old_file_size); + (int64_t)stat_buf.st_size, old_file_size); return EEXIST; } diff --git a/storage/storage_sync.c b/storage/storage_sync.c index 90c0fa6..982ba9a 100644 --- a/storage/storage_sync.c +++ b/storage/storage_sync.c @@ -151,11 +151,12 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \ "sync data file, logic file: %s " \ "on dest server %s:%d already exists, "\ "but file size: %"PRId64 \ - " not same as mine: "OFF_PRINTF_FORMAT\ + " not same as mine: %"PRId64 \ ", need re-sync it", __LINE__, \ pRecord->filename, pStorageServer->ip_addr,\ pStorageServer->port, \ - file_info.file_size, stat_buf.st_size); + file_info.file_size, \ + (int64_t)stat_buf.st_size); proto_cmd = STORAGE_PROTO_CMD_SYNC_UPDATE_FILE; } diff --git a/tracker/tracker_service.c b/tracker/tracker_service.c index 0f3e870..2003ae3 100644 --- a/tracker/tracker_service.c +++ b/tracker/tracker_service.c @@ -1985,9 +1985,9 @@ static int tracker_deal_get_one_sys_file(struct fast_task_info *pTask) { logError("file: "__FILE__", line: %d, " \ "client ip: %s, invalid offset: %"PRId64 - " < 0 or > "OFF_PRINTF_FORMAT, \ + " < 0 or > %"PRId64, \ __LINE__, pTask->client_ip, offset, \ - file_stat.st_size); + (int64_t)file_stat.st_size); pTask->length = sizeof(TrackerHeader); return EINVAL;