diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c index 9d4de06b0fb2297412fea0fdb24c326071ee8222..94f3901dd8fa52313aa621672e9dd612759123ab 100644 --- a/src/kit/shell/src/shellLinux.c +++ b/src/kit/shell/src/shellLinux.c @@ -86,7 +86,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { wordfree(&full_path); return -1; } - strcpy(configDir, full_path.we_wordv[0]); + tstrncpy(configDir, full_path.we_wordv[0], TSDB_FILENAME_LEN); wordfree(&full_path); break; case 's': @@ -100,7 +100,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { fprintf(stderr, "Invalid path %s\n", arg); return -1; } - strcpy(arguments->file, full_path.we_wordv[0]); + tstrncpy(arguments->file, full_path.we_wordv[0], TSDB_FILENAME_LEN); wordfree(&full_path); break; case 'D': @@ -108,7 +108,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { fprintf(stderr, "Invalid path %s\n", arg); return -1; } - strcpy(arguments->dir, full_path.we_wordv[0]); + tstrncpy(arguments->dir, full_path.we_wordv[0], TSDB_FILENAME_LEN); wordfree(&full_path); break; case 'T': diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index dea05e1c2a423d0b794724f8217e2216c7e24807..678de7daa78ea5d3963bb97a5fde42b8f214ac7b 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -655,7 +655,7 @@ int taosDumpDb(SDbInfo *dbInfo, SDumpArguments *arguments, FILE *fp) { } close(fd); - remove(".table.tmp"); + (void)remove(".table.tmp"); return 0; } diff --git a/src/os/linux/src/linuxSysPara.c b/src/os/linux/src/linuxSysPara.c index 04fa6b1f568d6ae0785d817e8666e86b1373ab6d..a1d013fa726c240eb42a525d6b7e8923a8e393f5 100644 --- a/src/os/linux/src/linuxSysPara.c +++ b/src/os/linux/src/linuxSysPara.c @@ -553,7 +553,7 @@ void taosSetCoreDump() { struct rlimit rlim; struct rlimit rlim_new; if (getrlimit(RLIMIT_CORE, &rlim) == 0) { - uPrint("the old unlimited para: rlim_cur=%" PRIu64, ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max); + uPrint("the old unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max); rlim_new.rlim_cur = RLIM_INFINITY; rlim_new.rlim_max = RLIM_INFINITY; if (setrlimit(RLIMIT_CORE, &rlim_new) != 0) { @@ -565,7 +565,7 @@ void taosSetCoreDump() { } if (getrlimit(RLIMIT_CORE, &rlim) == 0) { - uPrint("the new unlimited para: rlim_cur=%" PRIu64, ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max); + uPrint("the new unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max); } #ifndef _TD_ARM_ diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index 94084b5638a497e07a6ab4bd29fa51749d671dfb..23d8348cbe5def10d447af4da44aa3fdbe17d183 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -135,7 +135,7 @@ char* strtolower(char *dst, const char *src); int64_t strnatoi(char *num, int32_t len); -char* strreplace(const char* str, const char* pattern, const char* rep); +//char* strreplace(const char* str, const char* pattern, const char* rep); char *strbetween(char *string, char *begin, char *end); diff --git a/src/util/src/tnote.c b/src/util/src/tnote.c index aa618985431155cef80590bb9c4ef618b3be2704..12a7fc2b9b6174cced2446a8ebe80ebb1da97b00 100644 --- a/src/util/src/tnote.c +++ b/src/util/src/tnote.c @@ -208,14 +208,15 @@ int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInf } } - sprintf(name, "%s.%d", pNote->taosNoteName, pNote->taosNoteFlag); + char noteName[NOTE_FILE_NAME_LEN * 2] = "\0"; + sprintf(noteName, "%s.%d", pNote->taosNoteName, pNote->taosNoteFlag); pthread_mutex_init(&pNote->taosNoteMutex, NULL); umask(0); - pNote->taosNoteFd = open(name, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); + pNote->taosNoteFd = open(noteName, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); if (pNote->taosNoteFd < 0) { - fprintf(stderr, "failed to open note file:%s reason:%s\n", name, strerror(errno)); + fprintf(stderr, "failed to open note file:%s reason:%s\n", noteName, strerror(errno)); return -1; } taosLockNote(pNote->taosNoteFd, pNote); @@ -223,7 +224,7 @@ int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInf // only an estimate for number of lines struct stat filestat; if (fstat(pNote->taosNoteFd, &filestat) < 0) { - fprintf(stderr, "failed to fstat note file:%s reason:%s\n", name, strerror(errno)); + fprintf(stderr, "failed to fstat note file:%s reason:%s\n", noteName, strerror(errno)); return -1; } size = (int)filestat.st_size; diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index ccdf7111a7264726d35a4bf938e851b1fa5c3edf..2bfef63f846d9cebd929c4cedf2485619194113d 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -314,6 +314,7 @@ int64_t strnatoi(char *num, int32_t len) { return ret; } +#if 0 FORCE_INLINE size_t getLen(size_t old, size_t size) { if (old == 1) { old = 2; @@ -401,6 +402,7 @@ char *strreplace(const char *str, const char *pattern, const char *rep) { return dest; } +#endif char *strbetween(char *string, char *begin, char *end) { char *result = NULL; diff --git a/src/util/tests/stringTest.cpp b/src/util/tests/stringTest.cpp index 0dc1ee7a778f700c5e2d54f3dfe1325ceff06252..95fba0cd3e2b62da2b2dadb0b7e592aef5893543 100644 --- a/src/util/tests/stringTest.cpp +++ b/src/util/tests/stringTest.cpp @@ -26,6 +26,7 @@ TEST(testCase, string_dequote_test) { EXPECT_EQ(3, lx); } +#if 0 TEST(testCase, string_replace_test) { char t3[] = "abc01abc02abc"; char* ret = strreplace(t3, "abc", "7"); @@ -87,6 +88,7 @@ TEST(testCase, string_replace_test) { EXPECT_STREQ("abcdef", ret); free(ret); } +#endif TEST(testCase, string_tolower_test) { char t[1024] = {1};