READY: Resolve "Enforce code format"

In discussion with all developers, we decided on a code style, reflected by clang-format. The push includes the following changes:

  • clang-format is now mandatory for development and code must be properly formatted to be able to push to master
  • A check if the code is properly formatted by the given .clang-format style file, is now part of the CI pipeline test
  • The style file was tested on version 10 and 12 with the style file adhering to version 10.
  • A new script scripts/check_format.sh has been added which is used by CI but can also be used by the user for two tasks:
    • Check if any files need to be formatted
    • Pass -r to reformat all files in place with clang-format
  • All code has been reformatted to the decided style

Closes #121 (closed)

Edited by Marc Vef

Merge request reports

Loading
+12 −1
Changes for docker/debian_build_env.docker: 12 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -41,8 +41,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
		python3-dev \
		python3-venv \
		expect \
		# clang 10 deps
		lsb-release \
		wget \
		software-properties-common \
		gnupg2 \
# add clang-10 repos
&& wget https://apt.llvm.org/llvm.sh -P /tmp && chmod +x /tmp/llvm.sh && /tmp/llvm.sh 10 \
# install clang-format
&& apt-get update && apt-get install -y --no-install-recommends clang-format-10 \
# Clean apt cache to reduce image layer size
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* && rm /tmp/llvm.sh \
# Clean apt caches of packages
&& apt-get clean && apt-get autoclean

## COPY scripts/dl_dep.sh		$SCRIPTS_PATH/
## COPY scripts/compile_dep.sh $SCRIPTS_PATH/
+13 −6
Changes for include/client/rpc/forward_data.hpp: 13 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -24,16 +24,23 @@ struct ChunkStat {
    unsigned long chunk_free;
};

// TODO once we have LEAF, remove all the error code returns and throw them as an exception.
// TODO once we have LEAF, remove all the error code returns and throw them as
// an exception.

std::pair<int, ssize_t> forward_write(const std::string& path, const void* buf, bool append_flag, off64_t in_offset,
                                      size_t write_size, int64_t updated_metadentry_size);
std::pair<int, ssize_t>
forward_write(const std::string& path, const void* buf, bool append_flag,
              off64_t in_offset, size_t write_size,
              int64_t updated_metadentry_size);

std::pair<int, ssize_t> forward_read(const std::string& path, void* buf, off64_t offset, size_t read_size);
std::pair<int, ssize_t>
forward_read(const std::string& path, void* buf, off64_t offset,
             size_t read_size);

int forward_truncate(const std::string& path, size_t current_size, size_t new_size);
int
forward_truncate(const std::string& path, size_t current_size, size_t new_size);

std::pair<int, ChunkStat> forward_get_chunk_stat();
std::pair<int, ChunkStat>
forward_get_chunk_stat();

} // namespace rpc
} // namespace gkfs
+2 −1
Changes for include/client/rpc/forward_management.hpp: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@
namespace gkfs {
namespace rpc {

bool forward_get_fs_config();
bool
forward_get_fs_config();

} // namespace rpc
} // namespace gkfs
+23 −11
Changes for include/client/rpc/forward_metadata.hpp: 23 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -27,33 +27,45 @@ namespace metadata {
struct MetadentryUpdateFlags;

class Metadata;
}
} // namespace metadata

// TODO once we have LEAF, remove all the error code returns and throw them as an exception.
// TODO once we have LEAF, remove all the error code returns and throw them as
// an exception.

namespace rpc {

int forward_create(const std::string& path, mode_t mode);
int
forward_create(const std::string& path, mode_t mode);

int forward_stat(const std::string& path, std::string& attr);
int
forward_stat(const std::string& path, std::string& attr);

int forward_remove(const std::string& path, bool remove_metadentry_only, ssize_t size);
int
forward_remove(const std::string& path, bool remove_metadentry_only,
               ssize_t size);

int forward_decr_size(const std::string& path, size_t length);
int
forward_decr_size(const std::string& path, size_t length);

int forward_update_metadentry(const std::string& path, const gkfs::metadata::Metadata& md,
int
forward_update_metadentry(
        const std::string& path, const gkfs::metadata::Metadata& md,
        const gkfs::metadata::MetadentryUpdateFlags& md_flags);

std::pair<int, off64_t>
forward_update_metadentry_size(const std::string& path, size_t size, off64_t offset, bool append_flag);
forward_update_metadentry_size(const std::string& path, size_t size,
                               off64_t offset, bool append_flag);

std::pair<int, off64_t> forward_get_metadentry_size(const std::string& path);
std::pair<int, off64_t>
forward_get_metadentry_size(const std::string& path);

std::pair<int, std::shared_ptr<gkfs::filemap::OpenDir>> forward_get_dirents(const std::string& path);
std::pair<int, std::shared_ptr<gkfs::filemap::OpenDir>>
forward_get_dirents(const std::string& path);

#ifdef HAS_SYMLINKS

int forward_mk_symlink(const std::string& path, const std::string& target_path);
int
forward_mk_symlink(const std::string& path, const std::string& target_path);

#endif

+333 −463

File changed.

Preview size limit exceeded, changes collapsed.

Loading
Loading