From 965dc90b72a710b2400184e123316c8d1c8d4cf5 Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Wed, 16 Aug 2023 15:38:59 +0800 Subject: [PATCH] change return type to be consistant (#12479) Currently rdbSaveMillisecondTime, rdbSaveDoubleValue api's return type is int but they return the value directly from rdbWriteRaw function which has the return type of ssize_t. As this may cause overflow to int so changed to ssize_t. --- src/rdb.c | 4 ++-- src/rdb.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rdb.c b/src/rdb.c index ed30b6523..2c39df325 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -137,7 +137,7 @@ time_t rdbLoadTime(rio *rdb) { return (time_t)t32; } -int rdbSaveMillisecondTime(rio *rdb, long long t) { +ssize_t rdbSaveMillisecondTime(rio *rdb, long long t) { int64_t t64 = (int64_t) t; memrev64ifbe(&t64); /* Store in little endian. */ return rdbWriteRaw(rdb,&t64,8); @@ -583,7 +583,7 @@ robj *rdbLoadEncodedStringObject(rio *rdb) { * 254: + inf * 255: - inf */ -int rdbSaveDoubleValue(rio *rdb, double val) { +ssize_t rdbSaveDoubleValue(rio *rdb, double val) { unsigned char buf[128]; int len; diff --git a/src/rdb.h b/src/rdb.h index 234bde221..df1095d88 100644 --- a/src/rdb.h +++ b/src/rdb.h @@ -147,7 +147,7 @@ int rdbSaveType(rio *rdb, unsigned char type); int rdbLoadType(rio *rdb); time_t rdbLoadTime(rio *rdb); int rdbSaveLen(rio *rdb, uint64_t len); -int rdbSaveMillisecondTime(rio *rdb, long long t); +ssize_t rdbSaveMillisecondTime(rio *rdb, long long t); long long rdbLoadMillisecondTime(rio *rdb, int rdbver); uint64_t rdbLoadLen(rio *rdb, int *isencoded); int rdbLoadLenByRef(rio *rdb, int *isencoded, uint64_t *lenptr);