Skip to content

Commit da1ba1a

Browse files
committed
Various style tweaks
1 parent d749ff0 commit da1ba1a

File tree

8 files changed

+50
-60
lines changed

8 files changed

+50
-60
lines changed

src/cpdup.c

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ main(int ac, char **av)
407407
(long long)CountTargetReadBytes,
408408
(long long)CountWriteBytes,
409409
((double)CountSourceBytes * 2.0) / ((double)(CountSourceReadBytes + CountTargetReadBytes + CountWriteBytes)));
410-
logstd("%lld source items, %lld items copied, %lld items linked, "
410+
logstd("%lld source items, %lld items copied, %lld items linked, "
411411
"%lld things deleted\n",
412412
(long long)CountSourceItems,
413413
(long long)CountCopiedItems,
@@ -512,14 +512,14 @@ OwnerMatch(struct stat *st1, struct stat *st2)
512512
static int
513513
FlagsMatch(struct stat *st1, struct stat *st2)
514514
{
515-
/*
516-
* Ignore UF_ARCHIVE. It gets set automatically by the filesystem, for
517-
* filesystems that support it. If the destination filesystem supports it, but
518-
* it's cleared on the source file, then multiple invocations of cpdup would
519-
* all try to copy the file because the flags wouldn't match.
520-
*
521-
* When unpriveleged, ignore flags we can't set
522-
*/
515+
/*
516+
* Ignore UF_ARCHIVE. It gets set automatically by the filesystem, for
517+
* filesystems that support it. If the destination filesystem supports it,
518+
* but it's cleared on the source file, then multiple invocations of cpdup
519+
* would all try to copy the file because the flags wouldn't match.
520+
*
521+
* When unpriveleged, ignore flags we can't set
522+
*/
523523
u_long ignored = DstRootPrivs ? 0 : SF_SETTABLE;
524524

525525
#ifdef UF_ARCHIVE
@@ -539,7 +539,7 @@ hltlookup(struct stat *stp)
539539
n = stp->st_ino & HLMASK;
540540

541541
for (hl = hltable[n]; hl; hl = hl->next) {
542-
if (hl->ino == stp->st_ino) {
542+
if (hl->ino == stp->st_ino) {
543543
++hl->refs;
544544
return hl;
545545
}
@@ -775,13 +775,12 @@ DoCopy(copy_info_t info, struct stat *stat1, int depth)
775775
if (xlink(hln->name, dpath, stat1->st_flags) < 0) {
776776
int tryrelink = (errno == EMLINK);
777777
logerr("%-32s hardlink: unable to link to %s: %s\n",
778-
(dpath ? dpath : spath), hln->name, strerror(errno)
779-
);
778+
(dpath ? dpath : spath), hln->name, strerror(errno));
780779
hltdelete(hln);
781780
hln = NULL;
782781
if (tryrelink) {
783782
logerr("%-20s hardlink: will attempt to copy normally\n",
784-
(dpath ? dpath : spath));
783+
(dpath ? dpath : spath));
785784
goto relink;
786785
}
787786
++r;
@@ -792,10 +791,8 @@ DoCopy(copy_info_t info, struct stat *stat1, int depth)
792791
}
793792
if (r == 0) {
794793
if (VerboseOpt) {
795-
logstd("%-32s hardlink: %s\n",
796-
(dpath ? dpath : spath),
797-
(st2Valid ? "relinked" : "linked")
798-
);
794+
logstd("%-32s hardlink: %s\n", (dpath ? dpath : spath),
795+
(st2Valid ? "relinked" : "linked"));
799796
}
800797
CountSourceItems++;
801798
CountCopiedItems++;
@@ -920,9 +917,9 @@ DoCopy(copy_info_t info, struct stat *stat1, int depth)
920917
skipdir = 1;
921918
}
922919
if (hc_lstat(&DstHost, dpath, &st2) != 0) {
923-
if (NotForRealOpt == 0)
924-
logerr("%s: lstat of newly made dir failed: %s\n",
925-
(dpath ? dpath : spath), strerror(errno));
920+
if (!NotForRealOpt)
921+
logerr("%s: lstat of newly made dir failed: %s\n",
922+
(dpath ? dpath : spath), strerror(errno));
926923
st2Valid = 0;
927924
r = 1;
928925
skipdir = 1;
@@ -1093,14 +1090,14 @@ DoCopy(copy_info_t info, struct stat *stat1, int depth)
10931090
int fd2;
10941091

10951092
if (st2Valid)
1096-
path = mprintf("%s.tmp%d", dpath, (int)getpid());
1093+
path = mprintf("%s.tmp%d", dpath, (int)getpid());
10971094
else
1098-
path = mprintf("%s", dpath);
1095+
path = mprintf("%s", dpath);
10991096

1097+
#ifndef NOMD5
11001098
/*
11011099
* Handle check failure message.
11021100
*/
1103-
#ifndef NOMD5
11041101
if (mres < 0)
11051102
logerr("%-32s md5-CHECK-FAILED\n", (dpath) ? dpath : spath);
11061103
#endif
@@ -1461,11 +1458,11 @@ ScanDir(List *list, struct HostConf *host, const char *path,
14611458
* ignore . and ..
14621459
*/
14631460
if (strcmp(den->d_name, ".") != 0 && strcmp(den->d_name, "..") != 0) {
1464-
if (UseCpFile && UseCpFile[0] == '/') {
1465-
if (CheckList(list, path, den->d_name) == 0)
1466-
continue;
1467-
}
1468-
AddList(list, den->d_name, n, statptr);
1461+
if (UseCpFile && UseCpFile[0] == '/') {
1462+
if (CheckList(list, path, den->d_name) == 0)
1463+
continue;
1464+
}
1465+
AddList(list, den->d_name, n, statptr);
14691466
}
14701467
}
14711468
hc_closedir(host, dir);
@@ -1735,7 +1732,6 @@ YesNo(const char *path)
17351732
* destination and rename again. If that fails too, try to
17361733
* set the flags back the way they were and give up.
17371734
*/
1738-
17391735
static int
17401736
xrename(const char *src, const char *dst, u_long flags)
17411737
{

src/cpdup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ void debug_free(void *ptr);
144144

145145
#define malloc(bytes) debug_malloc(bytes, __FILE__, __LINE__)
146146
#define free(ptr) debug_free(ptr)
147-
#endif
147+
#endif /* DEBUG_MALLOC */

src/hclink.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -507,14 +507,14 @@ hcc_nextitem(hctransaction_t trans, struct HCHead *head, struct HCLeaf *item)
507507
item->leafid = hc_bswap16(item->leafid);
508508
item->bytes = hc_bswap32(item->bytes);
509509
switch (item->leafid & LCF_TYPEMASK) {
510-
case LCF_INT32:
511-
i32ptr = (void *)(item + 1);
512-
*i32ptr = hc_bswap32(*i32ptr);
513-
break;
514-
case LCF_INT64:
515-
i64ptr = (void *)(item + 1);
516-
*i64ptr = hc_bswap64(*i64ptr);
517-
break;
510+
case LCF_INT32:
511+
i32ptr = (void *)(item + 1);
512+
*i32ptr = hc_bswap32(*i32ptr);
513+
break;
514+
case LCF_INT64:
515+
i64ptr = (void *)(item + 1);
516+
*i64ptr = hc_bswap64(*i64ptr);
517+
break;
518518
}
519519
}
520520
assert(head->bytes >= offset + (int)sizeof(*item));
@@ -565,7 +565,7 @@ hcc_debug_dump(hctransaction_t trans, struct HCHead *head)
565565
fprintf(stderr, "\n");
566566
FOR_EACH_ITEM(item, trans, head) {
567567
fprintf(stderr, " ITEM %04x DATA ", item->leafid);
568-
switch(item->leafid & LCF_TYPEMASK) {
568+
switch (item->leafid & LCF_TYPEMASK) {
569569
case LCF_INT32:
570570
fprintf(stderr, "int32 %d\n", HCC_INT32(item));
571571
break;

src/hclink.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ struct HCDesc {
106106
#define HCC_INT64(item) (*(int64_t *)((item) + 1))
107107
#define HCC_BINARYDATA(item) ((void *)((item) + 1))
108108

109-
#define FOR_EACH_ITEM(item, trans, head) \
110-
for (item = hcc_firstitem(trans, head); item; \
111-
item = hcc_nextitem(trans, head, item))
109+
#define FOR_EACH_ITEM(item, trans, head) \
110+
for (item = hcc_firstitem(trans, head); item; \
111+
item = hcc_nextitem(trans, head, item))
112112

113113
/*
114114
* Prototypes
@@ -136,5 +136,4 @@ struct HCLeaf *hcc_currentchaineditem(struct HostConf *hc, struct HCHead *head);
136136

137137
void hcc_debug_dump(struct HCHead *head);
138138

139-
#endif
140-
139+
#endif /* !_HCLINK_H_ */

src/hcproto.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@ rc_closedir(hctransaction_t trans, struct HCHead *head)
634634
if (item->leafid == LC_DESCRIPTOR) {
635635
dir = hcc_get_descriptor(trans->hc, HCC_INT32(item), HC_DESC_DIR);
636636
if (dir != NULL) {
637-
hcc_set_descriptor(trans->hc, HCC_INT32(item),
638-
NULL, HC_DESC_DIR);
637+
hcc_set_descriptor(trans->hc, HCC_INT32(item),
638+
NULL, HC_DESC_DIR);
639639
}
640640
}
641641
}
@@ -1966,9 +1966,9 @@ rc_utimes(hctransaction_t trans, struct HCHead *head)
19661966
if (path == NULL)
19671967
return(-2);
19681968
if (head->cmd == HC_LUTIMES)
1969-
return(lutimes(path, times));
1969+
return(lutimes(path, times));
19701970
else
1971-
return(utimes(path, times));
1971+
return(utimes(path, times));
19721972
}
19731973

19741974
uid_t

src/hcproto.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,4 @@ int hc_lutimes(struct HostConf *hc, const char *path, const struct timeval *time
155155
uid_t hc_geteuid(struct HostConf *hc);
156156
int hc_getgroups(struct HostConf *hc, gid_t **gidlist);
157157

158-
#endif
159-
158+
#endif /* !_HCPROTO_H_ */

src/md5.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,12 @@ md5_flush(void)
5858
MD5Node *node;
5959
FILE *fo;
6060

61-
if (MD5SCacheDirty && MD5SCache && !NotForRealOpt) {
61+
if (MD5SCacheDirty && MD5SCache != NULL && !NotForRealOpt) {
6262
if ((fo = fopen(MD5SCache, "w")) != NULL) {
6363
for (node = MD5Base; node; node = node->md_Next) {
6464
if (node->md_Accessed && node->md_Code[0] != '\0') {
65-
fprintf(fo, "%s %zu %s\n",
66-
node->md_Code,
67-
strlen(node->md_Name),
68-
node->md_Name
69-
);
65+
fprintf(fo, "%s %zu %s\n", node->md_Code,
66+
strlen(node->md_Name), node->md_Name);
7067
}
7168
}
7269
fclose(fo);
@@ -78,7 +75,7 @@ md5_flush(void)
7875

7976
MD5SCacheDirty = 0;
8077

81-
if (MD5SCache) {
78+
if (MD5SCache != NULL) {
8279
while ((node = MD5Base) != NULL) {
8380
MD5Base = node->md_Next;
8481

@@ -99,9 +96,8 @@ md5_cache(const char *spath, int sdirlen)
9996
/*
10097
* Already cached
10198
*/
102-
10399
if (
104-
MD5SCache &&
100+
MD5SCache != NULL &&
105101
sdirlen == MD5SCacheDirLen &&
106102
strncmp(spath, MD5SCache, sdirlen) == 0
107103
) {

src/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ debug_free(void *ptr)
149149
}
150150
}
151151

152-
#endif
152+
#endif /* DEBUG_MALLOC */
153153

154154
void
155155
fatal(const char *ctl, ...)

0 commit comments

Comments
 (0)