Skip to content

Commit 17c4304

Browse files
committed
clang-format
1 parent a681107 commit 17c4304

File tree

3 files changed

+48
-46
lines changed

3 files changed

+48
-46
lines changed

src/logging.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ int SetupErrorLog(WORKSPACE *ws, char qGUILaunch) {
185185
return TZ_OK;
186186

187187
if (!(ws->pszErrorLogFile = malloc(sz))) {
188-
fprintf(stderr,"Error allocating memory!\n");
188+
fprintf(stderr, "Error allocating memory!\n");
189189
return TZ_CRITICAL;
190190
}
191-
snprintf(ws->pszErrorLogFile, sz, "%s%s%s", ws->pszLogDir,
192-
sep + has_sep, szErrorLogName);
191+
snprintf(ws->pszErrorLogFile, sz, "%s%s%s", ws->pszLogDir, sep + has_sep,
192+
szErrorLogName);
193193
}
194194

195195
rc = stat(ws->pszErrorLogFile, &istat);

src/trrntzip.c

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -160,30 +160,29 @@ static int GetFileList(unzFile UnZipHandle, WORKSPACE *ws) {
160160
if (unzGetGlobalInfo64(UnZipHandle, &GlobalInfo) != UNZ_OK)
161161
return TZ_ERR;
162162

163-
if (!(ws->FileNameArray =
164-
DynamicStringArrayGrow(ws->FileNameArray, &ws->iElements,
165-
GlobalInfo.number_entry + 1)))
163+
if (!(ws->FileNameArray = DynamicStringArrayGrow(
164+
ws->FileNameArray, &ws->iElements, GlobalInfo.number_entry + 1)))
166165
return TZ_CRITICAL;
167166

168167
if (GlobalInfo.number_entry != 0)
169168
rc = unzGoToFirstFile(UnZipHandle);
170169

171-
for (iCount = 0;
172-
rc == UNZ_OK && iCount < GlobalInfo.number_entry;
170+
for (iCount = 0; rc == UNZ_OK && iCount < GlobalInfo.number_entry;
173171
iCount++, rc = unzGoToNextFile(UnZipHandle)) {
174172
unz_file_info64 ZipInfo;
175173

176174
rc = unzGetCurrentFileInfo64(UnZipHandle, &ZipInfo,
177-
ws->FileNameArray[iCount], MAX_PATH,
178-
NULL, 0, NULL, 0);
175+
ws->FileNameArray[iCount], MAX_PATH, NULL, 0,
176+
NULL, 0);
179177
if (rc != UNZ_OK || ZipInfo.size_filename >= MAX_PATH ||
180178
ZipInfo.size_filename == 0)
181179
break;
182180
}
183181
ws->FileNameArray[iCount][0] = 0;
184182

185183
return rc == UNZ_END_OF_LIST_OF_FILE && iCount == GlobalInfo.number_entry
186-
? TZ_OK : TZ_ERR;
184+
? TZ_OK
185+
: TZ_ERR;
187186
}
188187

189188
int CheckZipStatus(unz64_s *UnzipStream, WORKSPACE *ws) {
@@ -383,9 +382,11 @@ int MigrateZip(const char *zip_path, const char *pDir, WORKSPACE *ws,
383382
rc = GetFileList(UnZipHandle, ws);
384383
if (rc != TZ_OK) {
385384
logprint3(stderr, mig->fProcessLog, ErrorLog(ws),
386-
rc == TZ_CRITICAL ? "Error allocating memory!\n" :
387-
"Could not list contents of \"%s\". File is corrupted or "
388-
"contains entries with bad names.\n", szZipFileName);
385+
rc == TZ_CRITICAL
386+
? "Error allocating memory!\n"
387+
: "Could not list contents of \"%s\". File is corrupted or "
388+
"contains entries with bad names.\n",
389+
szZipFileName);
389390
unzClose(UnZipHandle);
390391
return rc;
391392
}
@@ -432,10 +433,9 @@ int MigrateZip(const char *zip_path, const char *pDir, WORKSPACE *ws,
432433

433434
tmpfd = mkstemp(szTmpZipFileName);
434435
if (tmpfd < 0) {
435-
logprint3(
436-
stderr, mig->fProcessLog, ErrorLog(ws),
437-
"!!!! Couldn't create a unique temporary file. %s. !!!!\n",
438-
strerror(errno));
436+
logprint3(stderr, mig->fProcessLog, ErrorLog(ws),
437+
"!!!! Couldn't create a unique temporary file. %s. !!!!\n",
438+
strerror(errno));
439439
unzClose(UnZipHandle);
440440
return TZ_CRITICAL;
441441
}
@@ -445,10 +445,9 @@ int MigrateZip(const char *zip_path, const char *pDir, WORKSPACE *ws,
445445
close(tmpfd);
446446

447447
if ((ZipHandle = zipOpen64(szTmpZipFileName, 0)) == NULL) {
448-
logprint3(
449-
stderr, mig->fProcessLog, ErrorLog(ws),
450-
"Error opening temporary zip file %s. Unable to process \"%s\"\n",
451-
szTmpZipFileName, szZipFileName);
448+
logprint3(stderr, mig->fProcessLog, ErrorLog(ws),
449+
"Error opening temporary zip file %s. Unable to process \"%s\"\n",
450+
szTmpZipFileName, szZipFileName);
452451
unzClose(UnZipHandle);
453452
remove(szTmpZipFileName);
454453
return TZ_ERR;
@@ -663,8 +662,8 @@ static char **GetDirFileList(DIR *dirp, int *piElements) {
663662

664663
while ((direntp = readdir(dirp))) {
665664
if (!(FileNameArray =
666-
DynamicStringArrayGrow(FileNameArray, piElements, iCount + 1)))
667-
return NULL;
665+
DynamicStringArrayGrow(FileNameArray, piElements, iCount + 1)))
666+
return NULL;
668667

669668
snprintf(FileNameArray[iCount], MAX_PATH + 1, "%s", direntp->d_name);
670669
iCount++;
@@ -926,26 +925,27 @@ int main(int argc, char **argv) {
926925
if (argv[iCount][0] == '-') {
927926
iOptionsFound++;
928927

929-
switch (tolower(argv[iCount][1])) {
928+
switch (tolower((unsigned char)argv[iCount][1])) {
930929
case '?':
931930
case 'h':
932-
fprintf(stdout, "%s",
933-
"TorrentZip v" TZ_VERSION "\n\n"
934-
"Copyright (C) 2005 - 2024 TorrentZip Team:\n"
935-
"\tStatMat, shindakun, Ultrasubmarine, r3nh03k, goosecreature, "
936-
"gordonj,\n\t0-wiz-0, A.Miller\n"
937-
"Homepage: https://github.com/0-wiz-0/trrntzip\n\n"
938-
"Usage: trrntzip [-dfghqsv] [-eFILE] [-lDIR] [PATH/ZIP FILE]\n\n"
939-
"Options:\n"
940-
"\t-h\t: show this help\n"
941-
"\t-d\t: strip sub-directories from zips\n"
942-
"\t-eFILE\t: write error log to FILE\n"
943-
"\t-f\t: force re-zip\n"
944-
"\t-g\t: skip interactive prompts\n"
945-
"\t-lDIR\t: write log files in DIR (empty to disable)\n"
946-
"\t-q\t: quiet mode\n"
947-
"\t-s\t: prevent sub-directory recursion\n"
948-
"\t-v\t: show version\n");
931+
fprintf(
932+
stdout, "%s",
933+
"TorrentZip v" TZ_VERSION "\n\n"
934+
"Copyright (C) 2005 - 2024 TorrentZip Team:\n"
935+
"\tStatMat, shindakun, Ultrasubmarine, r3nh03k, goosecreature, "
936+
"gordonj,\n\t0-wiz-0, A.Miller\n"
937+
"Homepage: https://github.com/0-wiz-0/trrntzip\n\n"
938+
"Usage: trrntzip [-dfghqsv] [-eFILE] [-lDIR] [PATH/ZIP FILE]\n\n"
939+
"Options:\n"
940+
"\t-h\t: show this help\n"
941+
"\t-d\t: strip sub-directories from zips\n"
942+
"\t-eFILE\t: write error log to FILE\n"
943+
"\t-f\t: force re-zip\n"
944+
"\t-g\t: skip interactive prompts\n"
945+
"\t-lDIR\t: write log files in DIR (empty to disable)\n"
946+
"\t-q\t: quiet mode\n"
947+
"\t-s\t: prevent sub-directory recursion\n"
948+
"\t-v\t: show version\n");
949949
return EXIT_SUCCESS;
950950

951951
case 'd':
@@ -996,7 +996,8 @@ int main(int argc, char **argv) {
996996

997997
if (argc < 2 || iOptionsFound == (argc - 1)) {
998998
fprintf(stderr, "trrntzip: missing path\n");
999-
fprintf(stderr, "Usage: trrntzip [-dfghqsv] [-eFILE] [-lDIR] [PATH/ZIP FILE]\n");
999+
fprintf(stderr,
1000+
"Usage: trrntzip [-dfghqsv] [-eFILE] [-lDIR] [PATH/ZIP FILE]\n");
10001001
#ifdef WIN32
10011002
// Prevent the command window from disappearing immediately when
10021003
// the user just clicks on the exe.

src/util.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ char **DynamicStringArrayGrow(char **FileNameArray, int *piElements,
156156
else if (iMinElements - *piElements >= (*piElements + ARRAY_ELEMENTS) / 4)
157157
iNewElements = iMinElements;
158158
else // grow geometrically
159-
iNewElements = *piElements < 2 ? ARRAY_ELEMENTS :
160-
*piElements < INT_MAX / 2 ? *piElements * 2 :
161-
*piElements < INT_MAX ? INT_MAX : 0;
159+
iNewElements = *piElements < 2 ? ARRAY_ELEMENTS
160+
: *piElements < INT_MAX / 2 ? *piElements * 2
161+
: *piElements < INT_MAX ? INT_MAX
162+
: 0;
162163

163164
return DynamicStringArrayResize(FileNameArray, piElements, iNewElements);
164165
}

0 commit comments

Comments
 (0)