Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
charmoniumQ committed Dec 7, 2024
1 parent a00da48 commit e916070
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 45 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

4 changes: 0 additions & 4 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,3 @@ test-dev: compile
pytest probe_src --failed-first --maxfail=1

pre-commit: fix-format-nix fix-ruff fix-format-rust fix-clippy check-clang compile check-mypy test-dev

pre-commit: fix-format-nix fix-ruff fix-format-rust fix-clippy clang-tidy compile check-mypy test-dev

on-push: check-format-nix check-ruff check-format-rust check-clippy clang-tidy compile check-mypy check-flake test-ci
25 changes: 0 additions & 25 deletions Makefile

This file was deleted.

16 changes: 9 additions & 7 deletions probe_src/libprobe/arena/test_arena.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
#include <string.h>
#include <sys/stat.h>
#define ARENA_PERROR
#define strncpy_s(dest, destsz, src, count) strncpy(dest, src, count)
#include "arena.h"
#define DEFAULT_ARENA_SIZE 4096
#define HELLO_WORLD_SIZE 12
#define HELLO_WORLD "hello world"

int main() {
struct stat stat_buf;
Expand All @@ -18,22 +20,22 @@ int main() {
}
errno = 0;
struct ArenaDir arena_dir;
int ret = arena_create(&arena_dir, AT_FDCWD, "arena_data", 4096);
int ret = arena_create(&arena_dir, AT_FDCWD, "arena_data", DEFAULT_ARENA_SIZE);
assert(ret == 0);
/* This will copy strings into the arena.
* Eventually, it will overflow the first arena, causing a second to be allocated.
* */
for (size_t i = 0; i < 4000; ++i) {
char* foo = arena_calloc(&arena_dir, 12, sizeof(char));
for (size_t i = 0; i < DEFAULT_ARENA_SIZE - HELLO_WORLD_SIZE - 1; ++i) {
char* foo = arena_calloc(&arena_dir, HELLO_WORLD_SIZE, sizeof(char));
assert(foo);
strncpy_s(foo, 12, "hello world", 12);
strncpy(foo, HELLO_WORLD, HELLO_WORLD_SIZE);
arena_uninstantiate_all_but_last(&arena_dir);
arena_uninstantiate_all_but_last(&arena_dir);
}
/* This is greater than the old capacity of the arena */
char* foo = arena_calloc(&arena_dir, 81920, sizeof(char));
char* foo = arena_calloc(&arena_dir, 2 * DEFAULT_ARENA_SIZE, sizeof(char));
assert(foo);
strncpy_s(foo, 40,"this is a reaaally long string", 40);
strncpy(foo, HELLO_WORLD, HELLO_WORLD_SIZE);
/* This next line is totally optional */
/* arena_destroy(&arena_dir); */
return 0;
Expand Down
5 changes: 3 additions & 2 deletions probe_src/libprobe/src/declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

#include <stdbool.h>

#define ARENA_USE_UNWRAPPED_LIBC
#ifndef NDEBUG
#define ARENA_PERROR
#define unwrapped_openat openat
#endif
#define ARENA_USE_UNWRAPPED_LIBC
#include "../arena/include/arena.h"

/*
Expand Down
3 changes: 1 addition & 2 deletions probe_src/libprobe/src/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ static __thread bool __thread_inited = false;

#include "../generated/libc_hooks.h"

#include "declarationss.h"
#include "declarations.h"

#include "util.h"


#include "../include/libprobe/prov_ops.h"

#include "global_state.c"
Expand Down
4 changes: 2 additions & 2 deletions probe_src/libprobe/src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static pid_t my_gettid(){
ret; \
})

static OWNED char* path_join(BORROWED char* path_buf, size_t left_size, BORROWED const char* left, size_t right_size, BORROWED const char* right) {
static OWNED char* path_join(BORROWED char* path_buf, int left_size, BORROWED const char* left, int right_size, BORROWED const char* right) {
if (left_size == -1) {
left_size = strlen(left);
}
Expand Down Expand Up @@ -234,7 +234,7 @@ static bool is_dir(const char* dir) {

static OWNED const char* dirfd_path(int dirfd) {
static char dirfd_proc_path[PATH_MAX];
CHECK_SNPRINTF(dirfd_proc_path, (unsigned long) PATH_MAX, "/proc/self/fd/%d", dirfd);
CHECK_SNPRINTF(dirfd_proc_path, PATH_MAX, "/proc/self/fd/%d", dirfd);
char* resolved_buffer = malloc(PATH_MAX);
const char* ret = unwrapped_realpath(dirfd_proc_path, resolved_buffer);
return ret;
Expand Down

0 comments on commit e916070

Please sign in to comment.