Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scholarsmate committed Nov 22, 2023
1 parent 471f74f commit afa66af
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 0 additions & 2 deletions core/src/examples/count_characters.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
* *
**********************************************************************************************************************/

#define __STDC_FORMAT_MACROS

#include <inttypes.h>
#include <omega_edit.h>
#include <omega_edit/character_counts.h>
Expand Down
1 change: 0 additions & 1 deletion core/src/examples/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
/**
* This application can be used to test out and demonstrate the Omega-Edit session profiler.
*/
#define __STDC_FORMAT_MACROS

#include <assert.h>
#include <ctype.h>
Expand Down
5 changes: 3 additions & 2 deletions core/src/examples/simple_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ void vpt_change_cbk(const omega_viewport_t *viewport_ptr, omega_viewport_event_t
char change_kind = viewport_event_ptr
? omega_change_get_kind_as_char((const omega_change_t *) (viewport_event_ptr))
: 'R';
fprintf(stdout, "%c: [%s]\n", change_kind, omega_viewport_get_data(viewport_ptr));
fprintf((FILE *) (omega_viewport_get_user_data_ptr(viewport_ptr)), "%c: [%s]\n", change_kind,
omega_viewport_get_data(viewport_ptr));
break;
}
default:
Expand All @@ -34,7 +35,7 @@ void vpt_change_cbk(const omega_viewport_t *viewport_ptr, omega_viewport_event_t

int main() {
omega_session_t *session_ptr = omega_edit_create_session(NULL, NULL, NULL, NO_EVENTS, NULL);
omega_edit_create_viewport(session_ptr, 0, 100, 0, vpt_change_cbk, NULL, VIEWPORT_EVT_CREATE | VIEWPORT_EVT_EDIT);
omega_edit_create_viewport(session_ptr, 0, 100, 0, vpt_change_cbk, stdout, VIEWPORT_EVT_CREATE | VIEWPORT_EVT_EDIT);
omega_edit_insert(session_ptr, 0, "Hello Weird!!!!", 0);
omega_edit_overwrite(session_ptr, 7, "orl", 0);
omega_edit_delete(session_ptr, 11, 3);
Expand Down
8 changes: 6 additions & 2 deletions core/src/examples/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
#include <omega_edit.h>
#include <stdio.h>

omega_byte_t to_lower(omega_byte_t byte, void *_unused) { return (omega_byte_t) tolower(byte); }
static inline omega_byte_t to_lower(omega_byte_t byte, __attribute__((unused)) void *_unused) {
return (omega_byte_t) tolower(byte);
}

omega_byte_t to_upper(omega_byte_t byte, void *_unused) { return (omega_byte_t) toupper(byte); }
static inline omega_byte_t to_upper(omega_byte_t byte, __attribute__((unused)) void *_unused) {
return (omega_byte_t) toupper(byte);
}

int main(int argc, char **argv) {
if (argc != 4) {
Expand Down
10 changes: 5 additions & 5 deletions core/src/lib/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int omega_util_compare_modification_times(const char *path1, const char *path2)
}

const char *omega_util_get_current_dir(char *buffer) {
static char buff[FILENAME_MAX];//create string buffer to hold path
static char buff[FILENAME_MAX]{};//create string buffer to hold path
if (!buffer) { buffer = buff; }
auto const path_str = fs::current_path().string();
assert(0 < path_str.length());
Expand All @@ -165,7 +165,7 @@ const char *omega_util_get_current_dir(char *buffer) {

char *omega_util_dirname(char const *path, char *buffer) {
assert(path);
static char buff[FILENAME_MAX];//create string buffer to hold path
static char buff[FILENAME_MAX]{};//create string buffer to hold path
if (!buffer) { buffer = buff; }
auto const dirname_str = fs::path(path).parent_path().string();
assert(0 <= dirname_str.length());
Expand All @@ -180,7 +180,7 @@ char *omega_util_basename(char const *path, char *buffer, int drop_suffix) {
assert(path);
assert(0 < strlen(path));
assert(FILENAME_MAX > strlen(path));
static char buff[FILENAME_MAX];//create string buffer to hold path
static char buff[FILENAME_MAX]{};//create string buffer to hold path
if (!buffer) { buffer = buff; }
auto const basename_str = (drop_suffix == 0) ? fs::path(path).filename().string() : fs::path(path).stem().string();
auto const len = basename_str.copy(buffer, basename_str.length());
Expand All @@ -191,7 +191,7 @@ char *omega_util_basename(char const *path, char *buffer, int drop_suffix) {

char *omega_util_file_extension(char const *path, char *buffer) {
assert(path);
static char buff[FILENAME_MAX];//create string buffer to hold path
static char buff[FILENAME_MAX]{};//create string buffer to hold path
if (!buffer) { buffer = buff; }
auto const path_str = fs::path(path).extension().string();
assert(0 <= path_str.length());
Expand All @@ -217,7 +217,7 @@ char *omega_util_normalize_path(char const *path, char *buffer) {

char *omega_util_available_filename(char const *path, char *buffer) {
assert(path);
static char buff[FILENAME_MAX];//create string buffer to hold path
static char buff[FILENAME_MAX]{};//create string buffer to hold path
if (!buffer) { buffer = buff; }
if (!omega_util_file_exists(path)) {
memcpy(buffer, path, strlen(path) + 1);
Expand Down
1 change: 1 addition & 0 deletions core/src/lib/impl_/model_segment_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum class model_segment_kind_t {
SEGMENT_READ, SEGMENT_INSERT
};

// NOTE: omega_model_segment_struct is used in internal_fwd_defs.hpp despite what sonarlint says
struct omega_model_segment_struct {
int64_t computed_offset{}; ///< Computed offset can differ from the change as segments move and split
int64_t computed_length{}; ///< Computed length can differ from the change as segments split
Expand Down
5 changes: 1 addition & 4 deletions core/src/lib/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#ifdef OMEGA_BUILD_WINDOWS

#include <fcntl.h>
#include <io.h>
#include <process.h>

Expand All @@ -32,10 +33,8 @@
#define getpid _getpid
#else

#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>

#ifndef O_BINARY
#define O_BINARY (0)
Expand All @@ -47,10 +46,8 @@
#include "impl_/macros.h"
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>


int omega_util_compute_mode(int mode) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/tests/omega_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using Catch::Matchers::EndsWith;
using Catch::Matchers::Equals;

const auto DATA_DIR = std::filesystem::current_path() / "data";
#define MAKE_PATH(path) (DATA_DIR / path).string().c_str()
#define MAKE_PATH(path) (DATA_DIR / (path)).string().c_str()

/**
* Sleep for the given number of seconds.
Expand Down Expand Up @@ -95,7 +95,7 @@ TEST_CASE("Buffer Shift", "[BufferShift]") {
REQUIRE_THAT(fill + 1, Equals((const char *) buffer));

// Reset the buffer
memcpy(buffer, fill, buff_len);
strcpy((char *)buffer, fill);
REQUIRE_THAT(fill, Equals((const char *) buffer));

// Shift the buffer 6 bits to the left
Expand Down

0 comments on commit afa66af

Please sign in to comment.