Skip to content

Commit

Permalink
Fix some clang-tidy findings.
Browse files Browse the repository at this point in the history
Mostly some missing includes.
  • Loading branch information
hzeller committed Sep 16, 2024
1 parent 64e00c5 commit 7b8a97a
Show file tree
Hide file tree
Showing 44 changed files with 338 additions and 138 deletions.
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ BraceWrapping:
ContinuationIndentWidth: 4
IndentAccessModifiers: false
IndentCaseLabels: false
IndentPPDirectives: AfterHash
IndentWidth: 4
15 changes: 12 additions & 3 deletions src/buffered-write-sequencer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@

#include "buffered-write-sequencer.h"

#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>

#include <cassert>
#include <csignal>
#include <cstdint>
#include <cstdlib>
#include <future>
#include <mutex>
#include <thread>
#include <utility>

#include "timg-time.h"

namespace timg {

Expand Down
6 changes: 3 additions & 3 deletions src/buffered-write-sequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#ifndef BUFFERED_WRITE_SEQUENCER_H_
#define BUFFERED_WRITE_SEQUENCER_H_

#include <signal.h>
#include <stddef.h>

#include <condition_variable>
#include <csignal>
#include <cstddef>
#include <cstdint>
#include <future>
#include <mutex>
#include <queue>
Expand Down
9 changes: 5 additions & 4 deletions src/framebuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

#include "framebuffer.h"

#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>

#include <cassert>
#include <cstdint>
#include <cstdio>
#include <cstring>

namespace timg {

rgba_t rgba_t::ParseColor(const char *color) {
Expand Down
7 changes: 3 additions & 4 deletions src/framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
#ifndef TIMG_FRAMEBUFFER_H
#define TIMG_FRAMEBUFFER_H

#include <math.h>
#include <stdint.h>
#include <string.h>

#include <cmath>
#include <cstdint>
#include <cstring>
#include <functional>
#include <initializer_list>

Expand Down
22 changes: 14 additions & 8 deletions src/graphics-magick-source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@
#include "graphics-magick-source.h"

#include <Magick++.h>
#include <assert.h>
#include <magick/image.h>
#include <math.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <strings.h>

#include <algorithm>

#include "terminal-canvas.h"
#include <cassert>
#include <cmath>
#include <csignal>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <exception>
#include <string>

#include "buffered-write-sequencer.h"
#include "display-options.h"
#include "framebuffer.h"
#include "renderer.h"
#include "timg-time.h"

static constexpr bool kDebug = false;
Expand Down
5 changes: 2 additions & 3 deletions src/graphics-magick-source.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
#ifndef GRAPHICS_MAGICK_SOURCE_H_
#define GRAPHICS_MAGICK_SOURCE_H_

#include <signal.h>

#include <csignal>
#include <string>
#include <vector>

#include "display-options.h"
#include "image-source.h"
#include "renderer.h"
#include "terminal-canvas.h"
#include "timg-time.h"

namespace timg {
Expand Down
13 changes: 8 additions & 5 deletions src/image-source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@

#include "image-source.h"

#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <string.h>
#include <netinet/in.h>
#include <strings.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include <cerrno>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <memory>
#include <sstream>
#include <string>
#include <utility>

// Various implementations for the factory.
#include "display-options.h"
#include "graphics-magick-source.h"
#include "jpeg-source.h"
#include "openslide-source.h"
Expand Down
10 changes: 10 additions & 0 deletions src/iterm2-canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@
#include "iterm2-canvas.h"

#include <cassert>
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <functional>
#include <memory>

#include "buffered-write-sequencer.h"
#include "display-options.h"
#include "terminal-canvas.h"
#include "thread-pool.h"
#include "timg-base64.h"
#include "timg-png.h"
#include "timg-time.h"

#define SCREEN_CURSOR_UP_FORMAT "\033[%dA" // Move cursor up given lines.
#define SCREEN_CURSOR_RIGHT_FORMAT "\033[%dC" // Move cursor right given cols
Expand Down
3 changes: 3 additions & 0 deletions src/iterm2-canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
#ifndef ITERM2_CANVAS_H
#define ITERM2_CANVAS_H

#include "buffered-write-sequencer.h"
#include "display-options.h"
#include "framebuffer.h"
#include "terminal-canvas.h"
#include "thread-pool.h"
#include "timg-time.h"

namespace timg {
// Implements https://iterm2.com/documentation-images.html
Expand Down
33 changes: 25 additions & 8 deletions src/jpeg-source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,36 @@
#include "jpeg-source.h"

#include <fcntl.h>
#include <libexif/exif-content.h>
#include <libexif/exif-data.h>
#include <stdint.h>
#include <string.h>
#include <libexif/exif-entry.h>
#include <libexif/exif-format.h>
#include <libexif/exif-ifd.h>
#include <libexif/exif-tag.h>
#include <libexif/exif-utils.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <turbojpeg.h>
#include <unistd.h>

#include <csignal>
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <memory>
#include <string>
#include <utility>

#include "terminal-canvas.h"
#include "buffered-write-sequencer.h"
#include "display-options.h"
#include "framebuffer.h"
#include "renderer.h"
#include "timg-time.h"

extern "C" {
extern "C" { // avutil is missing extern "C"
#include <libavutil/log.h>
#include <libavutil/pixfmt.h>
#include <libswscale/swscale.h>
}
Expand Down Expand Up @@ -200,9 +216,10 @@ bool JPEGSource::LoadAndScale(const DisplayOptions &opts, int, int) {

// Further scaling to desired target width/height
av_log_set_callback(dummy_log);
SwsContext *swsCtx = sws_getContext(
decode_width, decode_height, AV_PIX_FMT_RGBA, target_width,
target_height, AV_PIX_FMT_RGBA, SWS_BILINEAR, NULL, NULL, NULL);
SwsContext *swsCtx =
sws_getContext(decode_width, decode_height, AV_PIX_FMT_RGBA,
target_width, target_height, AV_PIX_FMT_RGBA,
SWS_BILINEAR, nullptr, nullptr, nullptr);
if (!swsCtx) return false;
image_.reset(new timg::Framebuffer(target_width, target_height));

Expand Down
6 changes: 5 additions & 1 deletion src/jpeg-source.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
#ifndef JPEG_SOURCE_H_
#define JPEG_SOURCE_H_

#include <csignal>
#include <memory>
#include <string>

#include "display-options.h"
#include "framebuffer.h"
#include "image-source.h"
#include "terminal-canvas.h"
#include "renderer.h"
#include "timg-time.h"

namespace timg {
// Special case for JPEG decoding, as we can make use of decode+rough_scale
Expand Down
12 changes: 12 additions & 0 deletions src/kitty-canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,22 @@

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <memory>

#include "buffered-write-sequencer.h"
#include "display-options.h"
#include "terminal-canvas.h"
#include "thread-pool.h"
#include "timg-base64.h"
#include "timg-png.h"
#include "timg-time.h"

#define SCREEN_CURSOR_UP_FORMAT "\033[%dA" // Move cursor up given lines.
#define SCREEN_CURSOR_RIGHT_FORMAT "\033[%dC" // Move cursor right given cols
Expand Down
3 changes: 3 additions & 0 deletions src/kitty-canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
#ifndef KITTY_CANVAS_H
#define KITTY_CANVAS_H

#include "buffered-write-sequencer.h"
#include "display-options.h"
#include "framebuffer.h"
#include "terminal-canvas.h"
#include "thread-pool.h"
#include "timg-time.h"

namespace timg {
// Implements https://sw.kovidgoyal.net/kitty/graphics-protocol.html
Expand Down
13 changes: 11 additions & 2 deletions src/openslide-source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,24 @@
#include <openslide.h>
#include <unistd.h>

#include <csignal>
#include <cstdarg>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <functional>
#include <limits>
#include <string>
#include <utility>

#include "buffered-write-sequencer.h"
#include "display-options.h"
#include "framebuffer.h"
#include "terminal-canvas.h"
#include "renderer.h"
#include "timg-time.h"

extern "C" {
#include <libavutil/log.h>
#include <libavutil/pixfmt.h>
#include <libswscale/swscale.h>
}

Expand Down
6 changes: 5 additions & 1 deletion src/openslide-source.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
#ifndef OPENSLIDE_SOURCE_H_
#define OPENSLIDE_SOURCE_H_

#include <csignal>
#include <memory>
#include <string>

#include "display-options.h"
#include "framebuffer.h"
#include "image-source.h"
#include "terminal-canvas.h"
#include "renderer.h"
#include "timg-time.h"

namespace timg {
// Special case for JPEG decoding, as we can make use of decode+rough_scale
Expand Down
6 changes: 5 additions & 1 deletion src/pdf-image-source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@

#include <cairo.h>
#include <poppler.h>
#include <stdlib.h>

#include <algorithm>
#include <csignal>
#include <filesystem>
#include <string>

#include "display-options.h"
#include "framebuffer.h"
#include "renderer.h"
#include "timg-time.h"

namespace fs = std::filesystem;

Expand Down
6 changes: 5 additions & 1 deletion src/pdf-image-source.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
#ifndef PDF_SOURCE_H_
#define PDF_SOURCE_H_

#include <csignal>
#include <memory>
#include <string>
#include <vector>

#include "display-options.h"
#include "framebuffer.h"
#include "image-source.h"
#include "terminal-canvas.h"
#include "renderer.h"
#include "timg-time.h"

namespace timg {
class PDFImageSource final : public ImageSource {
Expand Down
15 changes: 13 additions & 2 deletions src/qoi-image-source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,23 @@
#include "qoi-image-source.h"

#define QOI_IMPLEMENTATION
#include <stdlib.h>
#include "qoi.h"
//

#include <csignal>
#include <cstdarg>
#include <cstdlib>
#include <cstring>
#include <string>

#include "buffered-write-sequencer.h"
#include "display-options.h"
#include "framebuffer.h"
#include "qoi.h"
#include "renderer.h"
#include "timg-time.h"

extern "C" {
#include <libavutil/log.h>
#include <libavutil/pixfmt.h>
#include <libswscale/swscale.h>
}
Expand Down
Loading

0 comments on commit 7b8a97a

Please sign in to comment.