mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-09-27 16:59:01 +00:00
Fixed a warning for compiling C/C++ codes
This commit is contained in:
parent
528a61718d
commit
cfb19cce45
@ -2142,7 +2142,7 @@ bool S3fsCurl::GetResponseCode(long& responseCode, bool from_curl_handle) const
|
|||||||
//
|
//
|
||||||
bool S3fsCurl::RemakeHandle()
|
bool S3fsCurl::RemakeHandle()
|
||||||
{
|
{
|
||||||
S3FS_PRN_INFO3("Retry request. [type=%d][url=%s][path=%s]", type, url.c_str(), path.c_str());
|
S3FS_PRN_INFO3("Retry request. [type=%d][url=%s][path=%s]", static_cast<int>(type), url.c_str(), path.c_str());
|
||||||
|
|
||||||
if(REQTYPE::UNSET == type){
|
if(REQTYPE::UNSET == type){
|
||||||
return false;
|
return false;
|
||||||
@ -2444,7 +2444,7 @@ bool S3fsCurl::RemakeHandle()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
S3FS_PRN_ERR("request type is unknown(%d)", type);
|
S3FS_PRN_ERR("request type is unknown(%d)", static_cast<int>(type));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!S3fsCurl::AddUserAgent(hCurl)){ // put User-Agent
|
if(!S3fsCurl::AddUserAgent(hCurl)){ // put User-Agent
|
||||||
|
@ -218,7 +218,8 @@ bool FdManager::MakeRandomTempPath(const char* path, std::string& tmppath)
|
|||||||
{
|
{
|
||||||
char szBuff[64];
|
char szBuff[64];
|
||||||
|
|
||||||
sprintf(szBuff, NOCACHE_PATH_PREFIX_FORM, random()); // worry for performance, but maybe don't worry.
|
snprintf(szBuff, sizeof(szBuff), NOCACHE_PATH_PREFIX_FORM, random()); // worry for performance, but maybe don't worry.
|
||||||
|
szBuff[sizeof(szBuff) - 1] = '\0'; // for safety
|
||||||
tmppath = szBuff;
|
tmppath = szBuff;
|
||||||
tmppath += path ? path : "";
|
tmppath += path ? path : "";
|
||||||
return true;
|
return true;
|
||||||
|
@ -334,7 +334,8 @@ int FdEntity::OpenMirrorFile()
|
|||||||
// (do not care for threading, because allowed any value returned.)
|
// (do not care for threading, because allowed any value returned.)
|
||||||
//
|
//
|
||||||
char szfile[NAME_MAX + 1];
|
char szfile[NAME_MAX + 1];
|
||||||
sprintf(szfile, "%x.tmp", rand_r(&seed));
|
snprintf(szfile, sizeof(szfile), "%x.tmp", rand_r(&seed));
|
||||||
|
szfile[NAME_MAX] = '\0'; // for safety
|
||||||
mirrorpath = bupdir + "/" + szfile;
|
mirrorpath = bupdir + "/" + szfile;
|
||||||
|
|
||||||
// link mirror file to cache file
|
// link mirror file to cache file
|
||||||
|
@ -41,7 +41,8 @@ int main(int argc, const char *argv[])
|
|||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
char filepath[4096];
|
char filepath[4096];
|
||||||
sprintf(filepath, "%s\r", argv[1]);
|
snprintf(filepath, sizeof(filepath), "%s\r", argv[1]);
|
||||||
|
filepath[sizeof(filepath) - 1] = '\0'; // for safety
|
||||||
|
|
||||||
// create empty file
|
// create empty file
|
||||||
if(-1 == (fd = open(filepath, O_CREAT|O_RDWR, 0644))){
|
if(-1 == (fd = open(filepath, O_CREAT|O_RDWR, 0644))){
|
||||||
|
@ -73,27 +73,31 @@ bool TestMknod(const char* basepath, mode_t mode)
|
|||||||
case S_IFREG:
|
case S_IFREG:
|
||||||
str_mode = str_mode_reg;
|
str_mode = str_mode_reg;
|
||||||
dev = 0;
|
dev = 0;
|
||||||
sprintf(filepath, "%s.%s", basepath, str_ext_reg);
|
snprintf(filepath, sizeof(filepath), "%s.%s", basepath, str_ext_reg);
|
||||||
|
filepath[S3FS_TEST_PATH_MAX - 1] = '\0'; // for safety
|
||||||
break;
|
break;
|
||||||
case S_IFCHR:
|
case S_IFCHR:
|
||||||
str_mode = str_mode_chr;
|
str_mode = str_mode_chr;
|
||||||
dev = makedev(0, 0);
|
dev = makedev(0, 0);
|
||||||
sprintf(filepath, "%s.%s", basepath, str_ext_chr);
|
snprintf(filepath, sizeof(filepath), "%s.%s", basepath, str_ext_chr);
|
||||||
|
filepath[S3FS_TEST_PATH_MAX - 1] = '\0'; // for safety
|
||||||
break;
|
break;
|
||||||
case S_IFBLK:
|
case S_IFBLK:
|
||||||
str_mode = str_mode_blk;
|
str_mode = str_mode_blk;
|
||||||
dev = makedev((unsigned int)(259), 0); // temporary value
|
dev = makedev((unsigned int)(259), 0); // temporary value
|
||||||
sprintf(filepath, "%s.%s", basepath, str_ext_blk);
|
snprintf(filepath, sizeof(filepath), "%s.%s", basepath, str_ext_blk);
|
||||||
|
filepath[S3FS_TEST_PATH_MAX - 1] = '\0'; // for safety
|
||||||
break;
|
break;
|
||||||
case S_IFIFO:
|
case S_IFIFO:
|
||||||
str_mode = str_mode_fifo;
|
str_mode = str_mode_fifo;
|
||||||
dev = 0;
|
dev = 0;
|
||||||
sprintf(filepath, "%s.%s", basepath, str_ext_fifo);
|
snprintf(filepath, sizeof(filepath), "%s.%s", basepath, str_ext_fifo);
|
||||||
|
filepath[S3FS_TEST_PATH_MAX - 1] = '\0'; // for safety
|
||||||
break;
|
break;
|
||||||
case S_IFSOCK:
|
case S_IFSOCK:
|
||||||
str_mode = str_mode_sock;
|
str_mode = str_mode_sock;
|
||||||
dev = 0;
|
dev = 0;
|
||||||
snprintf(filepath, S3FS_TEST_PATH_MAX, "%s.%s", basepath, str_ext_sock);
|
snprintf(filepath, sizeof(filepath), "%s.%s", basepath, str_ext_sock);
|
||||||
filepath[S3FS_TEST_PATH_MAX - 1] = '\0'; // for safety
|
filepath[S3FS_TEST_PATH_MAX - 1] = '\0'; // for safety
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -58,7 +58,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// run sub-process for reading file(cat)
|
// run sub-process for reading file(cat)
|
||||||
char szCommand[1024];
|
char szCommand[1024];
|
||||||
sprintf(szCommand, "cat %s >/dev/null 2>&1", filepath);
|
snprintf(szCommand, sizeof(szCommand), "cat %s >/dev/null 2>&1", filepath);
|
||||||
|
szCommand[sizeof(szCommand) - 1] = '\0'; // for safety
|
||||||
if(0 != system(szCommand)){
|
if(0 != system(szCommand)){
|
||||||
fprintf(stderr, "[ERROR] Failed to run sub-process(cat).\n");
|
fprintf(stderr, "[ERROR] Failed to run sub-process(cat).\n");
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user