enh: simple changes

This commit is contained in:
Shengliang Guan 2024-12-09 08:16:14 +00:00
parent 5028191796
commit 68558b0116
2 changed files with 9 additions and 11 deletions

View File

@ -340,19 +340,14 @@ int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) {
wordexp_t full_path = {0};
int32_t code = wordexp(dirname, &full_path, 0);
switch (code) {
case 0:
if (code == 0 && full_path.we_wordv[0] != NULL) {
tstrncpy(outname, full_path.we_wordv[0], maxlen);
break;
case WRDE_NOSPACE:
wordfree(&full_path);
// FALL THROUGH
default:
return terrno = TSDB_CODE_INVALID_PARA;
return 0;
}
wordfree(&full_path);
return 0;
return terrno = TSDB_CODE_INVALID_PARA;
}
int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen) {

View File

@ -268,6 +268,9 @@ TEST(osDirTests, taosExpandDir) {
ret = taosExpandDir("/x123", fullpath, 1024);
EXPECT_EQ(ret, 0);
ret = taosExpandDir("", fullpath, 1024);
EXPECT_NE(ret, 0);
char dir2[2048] = {0};
for (int32_t i = 0; i < 2047; ++i) {
dir2[i] = '1';