mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-22 08:48:55 +00:00
Fixed a warning for compiling C/C++ codes
This commit is contained in:
parent
acea1d33f9
commit
5b93765802
@ -2142,7 +2142,7 @@ bool S3fsCurl::GetResponseCode(long& responseCode, bool from_curl_handle) const
|
||||
//
|
||||
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){
|
||||
return false;
|
||||
@ -2444,7 +2444,7 @@ bool S3fsCurl::RemakeHandle()
|
||||
break;
|
||||
|
||||
default:
|
||||
S3FS_PRN_ERR("request type is unknown(%d)", type);
|
||||
S3FS_PRN_ERR("request type is unknown(%d)", static_cast<int>(type));
|
||||
return false;
|
||||
}
|
||||
if(!S3fsCurl::AddUserAgent(hCurl)){ // put User-Agent
|
||||
|
@ -218,7 +218,8 @@ bool FdManager::MakeRandomTempPath(const char* path, std::string& tmppath)
|
||||
{
|
||||
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 += path ? path : "";
|
||||
return true;
|
||||
|
@ -334,7 +334,8 @@ int FdEntity::OpenMirrorFile()
|
||||
// (do not care for threading, because allowed any value returned.)
|
||||
//
|
||||
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;
|
||||
|
||||
// link mirror file to cache file
|
||||
|
@ -41,7 +41,8 @@ int main(int argc, const char *argv[])
|
||||
|
||||
int fd;
|
||||
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
|
||||
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:
|
||||
str_mode = str_mode_reg;
|
||||
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;
|
||||
case S_IFCHR:
|
||||
str_mode = str_mode_chr;
|
||||
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;
|
||||
case S_IFBLK:
|
||||
str_mode = str_mode_blk;
|
||||
dev = makedev((unsigned int)(259), 0); // temporary value
|
||||
sprintf(filepath, "%s.%s", basepath, str_ext_blk);
|
||||
dev = makedev((unsigned int)(259), 0); // temporary value
|
||||
snprintf(filepath, sizeof(filepath), "%s.%s", basepath, str_ext_blk);
|
||||
filepath[S3FS_TEST_PATH_MAX - 1] = '\0'; // for safety
|
||||
break;
|
||||
case S_IFIFO:
|
||||
str_mode = str_mode_fifo;
|
||||
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;
|
||||
case S_IFSOCK:
|
||||
str_mode = str_mode_sock;
|
||||
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
|
||||
break;
|
||||
default:
|
||||
|
@ -58,7 +58,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
// run sub-process for reading file(cat)
|
||||
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)){
|
||||
fprintf(stderr, "[ERROR] Failed to run sub-process(cat).\n");
|
||||
close(fd);
|
||||
|
Loading…
Reference in New Issue
Block a user