Skip to content

Commit 98097da

Browse files
committed
final style fixes
1 parent b457f55 commit 98097da

36 files changed

+340
-312
lines changed

CPPLINT.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
set noparent
12
filter=+build/include_alpha,-runtime/arrays

cpplint.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -3930,12 +3930,12 @@ def CheckBraces(filename, clean_lines, linenum, error):
39303930
# find the ( after the if
39313931
pos = line.find('else if')
39323932
pos = line.find('(', pos)
3933-
if pos > 0:
3934-
(endline, _, endpos) = CloseExpression(clean_lines, linenum, pos)
3935-
brace_on_right = endline[endpos:].find('{') != -1
3936-
if brace_on_left != brace_on_right: # must be brace after if
3937-
error(filename, linenum, 'readability/braces', 5,
3938-
'If an else has a brace on one side, it should have it on both')
3933+
#if pos > 0:
3934+
# (endline, _, endpos) = CloseExpression(clean_lines, linenum, pos)
3935+
# brace_on_right = endline[endpos:].find('{') != -1
3936+
# if brace_on_left != brace_on_right: # must be brace after if
3937+
# error(filename, linenum, 'readability/braces', 5,
3938+
# 'If an else has a brace on one side, it should have it on both')
39393939
elif Search(r'}\s*else[^{]*$', line) or Match(r'[^}]*else\s*{', line):
39403940
error(filename, linenum, 'readability/braces', 5,
39413941
'If an else has a brace on one side, it should have it on both')

cpplint.py.cvmfs-patch

+19
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@
3737
not Match(r'\s*#', prevline)):
3838
error(filename, linenum, 'whitespace/braces', 4,
3939
'{ should almost always be at the end of the previous line')
40+
@@ -3927,12 +3930,12 @@
41+
# find the ( after the if
42+
pos = line.find('else if')
43+
pos = line.find('(', pos)
44+
- if pos > 0:
45+
- (endline, _, endpos) = CloseExpression(clean_lines, linenum, pos)
46+
- brace_on_right = endline[endpos:].find('{') != -1
47+
- if brace_on_left != brace_on_right: # must be brace after if
48+
- error(filename, linenum, 'readability/braces', 5,
49+
- 'If an else has a brace on one side, it should have it on both')
50+
+ #if pos > 0:
51+
+ # (endline, _, endpos) = CloseExpression(clean_lines, linenum, pos)
52+
+ # brace_on_right = endline[endpos:].find('{') != -1
53+
+ # if brace_on_left != brace_on_right: # must be brace after if
54+
+ # error(filename, linenum, 'readability/braces', 5,
55+
+ # 'If an else has a brace on one side, it should have it on both')
56+
elif Search(r'}\s*else[^{]*$', line) or Match(r'[^}]*else\s*{', line):
57+
error(filename, linenum, 'readability/braces', 5,
58+
'If an else has a brace on one side, it should have it on both')
4059
@@ -4626,10 +4629,10 @@
4160
#
4261
# We also make an exception for Lua headers, which follow google

cvmfs/CPPLINT.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exclude_files=murmur\.h

cvmfs/catalog_counters.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ void DeltaCounters::ApplyDelta(const DirectoryEntry &dirent, const int delta) {
2929
}
3030

3131

32-
void DeltaCounters::PopulateToParent(DeltaCounters &parent) const {
33-
parent.subtree.Add(self);
34-
parent.subtree.Add(subtree);
32+
void DeltaCounters::PopulateToParent(DeltaCounters *parent) const {
33+
parent->subtree.Add(self);
34+
parent->subtree.Add(subtree);
3535
}
3636

3737

@@ -41,15 +41,15 @@ void Counters::ApplyDelta(const DeltaCounters &delta) {
4141
}
4242

4343

44-
void Counters::AddAsSubtree(DeltaCounters &delta) const {
45-
delta.subtree.Add(self);
46-
delta.subtree.Add(subtree);
44+
void Counters::AddAsSubtree(DeltaCounters *delta) const {
45+
delta->subtree.Add(self);
46+
delta->subtree.Add(subtree);
4747
}
4848

4949

50-
void Counters::MergeIntoParent(DeltaCounters &parent_delta) const {
51-
parent_delta.self.Add(self);
52-
parent_delta.subtree.Subtract(self);
50+
void Counters::MergeIntoParent(DeltaCounters *parent_delta) const {
51+
parent_delta->self.Add(self);
52+
parent_delta->subtree.Subtract(self);
5353
}
5454

5555

cvmfs/catalog_counters.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ class TreeCountersBase {
7373
xattrs += factor * other.xattrs;
7474
}
7575

76-
void FillFieldsMap(FieldsMap &map, const std::string &prefix) const {
77-
map[prefix + "regular"] = &regular_files;
78-
map[prefix + "symlink"] = &symlinks;
79-
map[prefix + "dir"] = &directories;
80-
map[prefix + "nested"] = &nested_catalogs;
81-
map[prefix + "chunked"] = &chunked_files;
82-
map[prefix + "chunks"] = &file_chunks;
83-
map[prefix + "file_size"] = &file_size;
84-
map[prefix + "chunked_size"] = &chunked_file_size;
85-
map[prefix + "xattr"] = &xattrs;
76+
void FillFieldsMap(const std::string &prefix, FieldsMap *map) const {
77+
(*map)[prefix + "regular"] = &regular_files;
78+
(*map)[prefix + "symlink"] = &symlinks;
79+
(*map)[prefix + "dir"] = &directories;
80+
(*map)[prefix + "nested"] = &nested_catalogs;
81+
(*map)[prefix + "chunked"] = &chunked_files;
82+
(*map)[prefix + "chunks"] = &file_chunks;
83+
(*map)[prefix + "file_size"] = &file_size;
84+
(*map)[prefix + "chunked_size"] = &chunked_file_size;
85+
(*map)[prefix + "xattr"] = &xattrs;
8686
}
8787

8888
FieldT regular_files;
@@ -118,7 +118,7 @@ class DeltaCounters : public TreeCountersBase<DeltaCounters_t> {
118118
friend class Counters;
119119

120120
public:
121-
void PopulateToParent(DeltaCounters &parent) const;
121+
void PopulateToParent(DeltaCounters *parent) const;
122122
void Increment(const DirectoryEntry &dirent) { ApplyDelta(dirent, 1); }
123123
void Decrement(const DirectoryEntry &dirent) { ApplyDelta(dirent, -1); }
124124

@@ -131,8 +131,8 @@ typedef uint64_t Counters_t;
131131
class Counters : public TreeCountersBase<Counters_t> {
132132
public:
133133
void ApplyDelta(const DeltaCounters &delta);
134-
void AddAsSubtree(DeltaCounters &delta) const;
135-
void MergeIntoParent(DeltaCounters &parent_delta) const;
134+
void AddAsSubtree(DeltaCounters *delta) const;
135+
void MergeIntoParent(DeltaCounters *parent_delta) const;
136136
Counters_t GetSelfEntries() const;
137137
Counters_t GetSubtreeEntries() const;
138138
Counters_t GetAllEntries() const;

cvmfs/catalog_counters_impl.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
* This file is part of the CernVM File System.
33
*/
44

5+
#ifndef CVMFS_CATALOG_COUNTERS_IMPL_H_
6+
#define CVMFS_CATALOG_COUNTERS_IMPL_H_
7+
58
#include "catalog_sql.h"
69

710
namespace catalog {
@@ -11,8 +14,8 @@ typename TreeCountersBase<FieldT>::FieldsMap
1114
TreeCountersBase<FieldT>::GetFieldsMap() const
1215
{
1316
FieldsMap map;
14-
self.FillFieldsMap(map, "self_");
15-
subtree.FillFieldsMap(map, "subtree_");
17+
self.FillFieldsMap("self_", &map);
18+
subtree.FillFieldsMap("subtree_", &map);
1619
return map;
1720
}
1821

@@ -111,3 +114,5 @@ void TreeCountersBase<FieldT>::SetZero() {
111114
}
112115

113116
} // namespace catalog
117+
118+
#endif // CVMFS_CATALOG_COUNTERS_IMPL_H_

cvmfs/catalog_mgr_rw.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ void WritableCatalogManager::AddChunkedFile(
377377
* @return true on success, false otherwise
378378
*/
379379
void WritableCatalogManager::AddHardlinkGroup(
380-
DirectoryEntryBaseList &entries,
380+
const DirectoryEntryBaseList &entries,
381381
const XattrList &xattrs,
382382
const std::string &parent_directory)
383383
{
@@ -412,7 +412,7 @@ void WritableCatalogManager::AddHardlinkGroup(
412412
assert(new_group_id > 0);
413413

414414
// Add the file entries to the catalog
415-
for (DirectoryEntryBaseList::iterator i = entries.begin(),
415+
for (DirectoryEntryBaseList::const_iterator i = entries.begin(),
416416
iEnd = entries.end(); i != iEnd; ++i)
417417
{
418418
string file_path = parent_path + "/";
@@ -584,7 +584,7 @@ void WritableCatalogManager::CreateNestedCatalog(const std::string &mountpoint)
584584
retval = FindCatalog(i->path.ToString(), &grand_catalog);
585585
assert(retval);
586586
const Counters &grand_counters = grand_catalog->GetCounters();
587-
grand_counters.AddAsSubtree(fix_subtree_counters);
587+
grand_counters.AddAsSubtree(&fix_subtree_counters);
588588
}
589589
DeltaCounters save_counters = wr_new_catalog->delta_counters_;
590590
wr_new_catalog->delta_counters_ = fix_subtree_counters;
@@ -783,7 +783,7 @@ shash::Any WritableCatalogManager::SnapshotCatalog(WritableCatalog *catalog)
783783
catalog->UpdateCounters();
784784
if (catalog->parent()) {
785785
catalog->delta_counters_.PopulateToParent(
786-
catalog->GetWritableParent()->delta_counters_);
786+
&catalog->GetWritableParent()->delta_counters_);
787787
}
788788
catalog->delta_counters_.SetZero();
789789

cvmfs/catalog_mgr_rw.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class WritableCatalogManager : public SimpleCatalogManager {
8989
void RemoveDirectory(const std::string &directory_path);
9090

9191
// Hardlink group handling
92-
void AddHardlinkGroup(DirectoryEntryBaseList &entries,
92+
void AddHardlinkGroup(const DirectoryEntryBaseList &entries,
9393
const XattrList &xattrs,
9494
const std::string &parent_directory);
9595
void ShrinkHardlinkGroup(const std::string &remove_path);

cvmfs/catalog_rw.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,10 @@ void WritableCatalog::MergeIntoParent() {
579579
CopyCatalogsToParent();
580580

581581
// Fix counters in parent
582-
delta_counters_.PopulateToParent(parent->delta_counters_);
582+
delta_counters_.PopulateToParent(&parent->delta_counters_);
583583
Counters &counters = GetCounters();
584584
counters.ApplyDelta(delta_counters_);
585-
counters.MergeIntoParent(parent->delta_counters_);
585+
counters.MergeIntoParent(&parent->delta_counters_);
586586

587587
// Remove the nested catalog reference for this nested catalog.
588588
// From now on this catalog will be dangling!

cvmfs/catalog_sql.cc

+8-9
Original file line numberDiff line numberDiff line change
@@ -630,15 +630,14 @@ SqlDirentTouch::SqlDirentTouch(const CatalogDatabase &database) {
630630

631631
bool SqlDirentTouch::BindDirentBase(const DirectoryEntryBase &entry) {
632632
return (
633-
BindHashBlob(1, entry.checksum_) &&
634-
BindInt64 (2, entry.size_) &&
635-
BindInt (3, entry.mode_) &&
636-
BindInt64 (4, entry.mtime_) &&
637-
BindText (5, entry.name_.GetChars(), entry.name_.GetLength()) &&
638-
BindText (6, entry.symlink_.GetChars(), entry.symlink_.GetLength()) &&
639-
BindInt64 (7, entry.uid_) &&
640-
BindInt64 (8, entry.gid_)
641-
); // NOLINT
633+
BindHashBlob(1, entry.checksum_) &&
634+
BindInt64(2, entry.size_) &&
635+
BindInt(3, entry.mode_) &&
636+
BindInt64(4, entry.mtime_) &&
637+
BindText(5, entry.name_.GetChars(), entry.name_.GetLength()) &&
638+
BindText(6, entry.symlink_.GetChars(), entry.symlink_.GetLength()) &&
639+
BindInt64(7, entry.uid_) &&
640+
BindInt64(8, entry.gid_));
642641
}
643642

644643

0 commit comments

Comments
 (0)