Skip to content

Commit

Permalink
Run through clang-format.
Browse files Browse the repository at this point in the history
  • Loading branch information
0-wiz-0 committed Jan 16, 2024
1 parent 91d1470 commit 29d141d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ int OpenProcessLog(const char *pszWritePath, const char *pszRelPath,
}

snprintf(szLogname, sizeof(szLogname),
"%s[%s]_[%04d-%02d-%02d - %02d-%02d-%02d].log",
pszWritePath, pszDirname, t->tm_year + 1900, t->tm_mon + 1,
t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
"%s[%s]_[%04d-%02d-%02d - %02d-%02d-%02d].log", pszWritePath,
pszDirname, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour,
t->tm_min, t->tm_sec);

mig->fProcessLog = OpenLog(szLogname);

Expand Down
41 changes: 23 additions & 18 deletions src/trrntzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ int MigrateZip(const char *zip_path, const char *pDir, WORKSPACE *ws,

// Sort filelist into canonical order
for (iArray = 0; iArray < ws->iElements && ws->FileNameArray[iArray][0];
iArray++);
iArray++)
;
qsort(ws->FileNameArray, iArray, sizeof(char *),
qStripSubdirs ? BasenameCompare : StringCompare);

Expand Down Expand Up @@ -458,9 +459,11 @@ int MigrateZip(const char *zip_path, const char *pDir, WORKSPACE *ws,
logprint3(
stderr, mig->fProcessLog, ws->fErrorLog,
"!!!! Couldn't create a unique temporary file%s. !!!!\n",
szTmpZipFileName[0] ? ", another process created it faster. "
"Running several instances of trrntzip concurrently on the same "
"directories can lead to data corruption" : "");
szTmpZipFileName[0]
? ", another process created it faster. "
"Running several instances of trrntzip concurrently on the same "
"directories can lead to data corruption"
: "");
unzClose(UnZipHandle);
return TZ_CRITICAL;
}
Expand Down Expand Up @@ -507,8 +510,8 @@ int MigrateZip(const char *zip_path, const char *pDir, WORKSPACE *ws,
if (pszZipName) {
if (!*++pszZipName) {
// Last char was '/' so is dir entry. Skip it.
logprint(stdout, mig->fProcessLog,
"Directory %s Removed\n", szFileName);
logprint(stdout, mig->fProcessLog, "Directory %s Removed\n",
szFileName);
continue;
}

Expand All @@ -521,8 +524,8 @@ int MigrateZip(const char *zip_path, const char *pDir, WORKSPACE *ws,
// check if the file is a DIR entry that should be removed
if (ShouldFileBeRemoved(iArray, ws)) {
// remove this file.
logprint(stdout, mig->fProcessLog,
"Directory %s Removed\n", szFileName);
logprint(stdout, mig->fProcessLog, "Directory %s Removed\n",
szFileName);
continue;
}
}
Expand All @@ -537,8 +540,8 @@ int MigrateZip(const char *zip_path, const char *pDir, WORKSPACE *ws,
}

logprint(stdout, mig->fProcessLog,
"Adding - %s (%" PRIu64 " bytes%s%s%s)...",
pszZipName, ZipInfo.uncompressed_size, (zip64 ? ", Zip64" : ""),
"Adding - %s (%" PRIu64 " bytes%s%s%s)...", pszZipName,
ZipInfo.uncompressed_size, (zip64 ? ", Zip64" : ""),
(pszZipName == szFileName ? "" : ", was: "),
(pszZipName == szFileName ? "" : szFileName));

Expand Down Expand Up @@ -677,7 +680,8 @@ int MigrateZip(const char *zip_path, const char *pDir, WORKSPACE *ws,
logprint3(
stderr, mig->fProcessLog, ws->fErrorLog,
"!!!! Could not rename temporary file \"%s\" to \"%s\". The original "
"file has already been deleted, so you must rename this file manually.\n",
"file has already been deleted, so you must rename this file "
"manually.\n",
szTmpZipFileName, szZipFileName);
#else
logprint3(stderr, mig->fProcessLog, ws->fErrorLog,
Expand Down Expand Up @@ -714,8 +718,8 @@ static char **GetDirFileList(DIR *dirp, int *piElements) {
while ((direntp = readdir(dirp))) {
if (iCount + 2 >= *piElements) {
// Grow array geometrically.
FileNameArray = DynamicStringArrayResize(FileNameArray, piElements,
*piElements * 2);
FileNameArray =
DynamicStringArrayResize(FileNameArray, piElements, *piElements * 2);
if (!FileNameArray)
return NULL;
}
Expand Down Expand Up @@ -1011,9 +1015,9 @@ int main(int argc, char **argv) {
break;

case 'q':
// Quiet mode - show less messages while running
qQuietMode = 1;
break;
// Quiet mode - show less messages while running
qQuietMode = 1;
break;

case 's':
// Disable dir recursion
Expand Down Expand Up @@ -1099,9 +1103,10 @@ int main(int argc, char **argv) {
} else if (qLogEmpty) {
// pszStartPath is not used (yet) by OpenErrorLog()
// keep the commented code (and stupid replacement) as a reminder
//snprintf(szErrorLogFileName, sizeof(szErrorLogFileName), "%s%c%s",
// snprintf(szErrorLogFileName, sizeof(szErrorLogFileName), "%s%c%s",
// pszStartPath, DIRSEP, "error.log");
snprintf(szErrorLogFileName, sizeof(szErrorLogFileName), "%s", "error.log");
snprintf(szErrorLogFileName, sizeof(szErrorLogFileName), "%s",
"error.log");

// Removing the log file which could still be open and written to by a
// different process is a bad idea. Deferring error log creation until
Expand Down

0 comments on commit 29d141d

Please sign in to comment.