Skip to content

Commit

Permalink
fix: conditional include of <linux/limits>
Browse files Browse the repository at this point in the history
refactor: format code

Signed-off-by: Rentib <[email protected]>
  • Loading branch information
Rentib committed Oct 19, 2024
1 parent 1a167a9 commit 6ecf2c7
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
#include "image.h"

#include <errno.h>
#include <linux/limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>

#if defined(__linux__)
#include <linux/limits.h>
#elif defined(__OpenBSD__) || defined(__FreeBSD__)
#define PATH_MAX 4096
#endif

struct image* image_create(void)
{
return calloc(1, sizeof(struct image));
Expand Down Expand Up @@ -98,15 +103,16 @@ static bool make_directories(char* path)

slash = path;
while (true) {
slash = strchr(slash + 1, '/');
if (!slash)
break;
*slash = '\0';
if (mkdir(path, 0755) && errno != EEXIST) {
// TODO: do we want to print error message?
return false;
}
*slash = '/';
slash = strchr(slash + 1, '/');
if (!slash) {
break;
}
*slash = '\0';
if (mkdir(path, 0755) && errno != EEXIST) {
// TODO: do we want to print error message?
return false;
}
*slash = '/';
}

return true;
Expand Down

0 comments on commit 6ecf2c7

Please sign in to comment.