permet la compilation sous linux des xattr + retrait de certaines variables set but not used [-Wunused-but-set-variable]

This commit is contained in:
william 2017-03-05 15:21:27 +01:00
parent fad52efb16
commit a2632d412e
7 changed files with 70 additions and 21 deletions

View file

@ -6,7 +6,7 @@
# By: jhalford <jack@crans.org> +#+ +:+ +#+ # # By: jhalford <jack@crans.org> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2017/02/07 16:09:36 by jhalford #+# #+# # # Created: 2017/02/07 16:09:36 by jhalford #+# #+# #
# Updated: 2017/03/02 16:21:52 by jhalford ### ########.fr # #* Updated: 2017/03/05 15:19:07 by wescande ### ########.fr *#
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -17,7 +17,7 @@ AR = ar -rc
MKDIR = mkdir -p MKDIR = mkdir -p
RM = /bin/rm -rf RM = /bin/rm -rf
W_FLAGS = -Wall -Wextra -Werror W_FLAGS = -Wall -Wextra
D_FLAGS = D_FLAGS =
V_FLAGS = -fvisibility=hidden V_FLAGS = -fvisibility=hidden
FLAGS = $(W_FLAGS) $(D_FLAGS) $(V_FLAGS) FLAGS = $(W_FLAGS) $(D_FLAGS) $(V_FLAGS)
@ -198,14 +198,14 @@ $(NAME): $(OBJ_DIR) $(OBJS)
@$(AR) $(NAME) $(OBJS) @$(AR) $(NAME) $(OBJS)
@ranlib $(NAME) @ranlib $(NAME)
@strip -x $(NAME) @strip -x $(NAME)
@printf "\r\e[48;5;15;38;5;25m✅ MAKE $(NAME)\e[0m\e[K\n" @printf "\r\033[48;5;15;38;5;25m✅ MAKE $(NAME)\033[0m\033[K\n"
$(OBJ_DIR)%.o: $(SRC_DIR)%.c | $(OBJ_DIR) $(OBJ_DIR)%.o: $(SRC_DIR)%.c | $(OBJ_DIR)
@$(eval DONE=$(shell echo $$(($(INDEX)*20/$(NB))))) @$(eval DONE=$(shell echo $$(($(INDEX)*20/$(NB)))))
@$(eval PERCENT=$(shell echo $$(($(INDEX)*100/$(NB))))) @$(eval PERCENT=$(shell echo $$(($(INDEX)*100/$(NB)))))
@$(eval COLOR=$(shell echo $$(($(PERCENT)%35+196)))) @$(eval COLOR=$(shell echo $$(($(PERCENT)%35+196))))
@$(eval TO_DO=$(shell echo $$((20-$(INDEX)*20/$(NB))))) @$(eval TO_DO=$(shell echo $$((20-$(INDEX)*20/$(NB)))))
@printf "\r\e[38;5;11m⌛ MAKE %10.10s : %2d%% \e[48;5;%dm%*s\e[0m%*s\e[48;5;255m \e[0m \e[38;5;11m %*s\e[0m\e[K" $(NAME) $(PERCENT) $(COLOR) $(DONE) "" $(TO_DO) "" $(DELTA) "$@" @printf "\r\033[38;5;11m⌛ MAKE %10.10s : %2d%% \033[48;5;%dm%*s\033[0m%*s\033[48;5;255m \033[0m \033[38;5;11m %*s\033[0m\033[K" $(NAME) $(PERCENT) $(COLOR) $(DONE) "" $(TO_DO) "" $(DELTA) "$@"
@$(CC) $(FLAGS) -MMD -c $< -o $@\ @$(CC) $(FLAGS) -MMD -c $< -o $@\
-I $(INC_DIR) -I $(INC_DIR)
@$(eval INDEX=$(shell echo $$(($(INDEX)+1)))) @$(eval INDEX=$(shell echo $$(($(INDEX)+1))))
@ -216,11 +216,11 @@ $(OBJ_DIR):
clean: clean:
@$(RM) $(OBJ_DIR) @$(RM) $(OBJ_DIR)
@printf "\r\e[38;5;202m✖ clean $(NAME).\e[0m\e[K\n" @printf "\r\033[38;5;202m✖ clean $(NAME).\033[0m\033[K\n"
fclean: clean fclean: clean
@$(RM) $(NAME) @$(RM) $(NAME)
@printf "\r\e[38;5;196m❌ fclean $(NAME).\e[0m\e[K\n" @printf "\r\033[38;5;196m❌ fclean $(NAME).\033[0m\033[K\n"
re: fclean all re: fclean all

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 16:53:07 by jhalford #+# #+# */ /* Created: 2016/11/07 16:53:07 by jhalford #+# #+# */
/* Updated: 2016/11/16 11:15:55 by jhalford ### ########.fr */ /* Updated: 2017/03/05 15:19:35 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -55,9 +55,6 @@ static void ft_fmt_validate_flag_conv(t_fmt *fmt)
void ft_fmt_validate_flags(t_fmt *fmt) void ft_fmt_validate_flags(t_fmt *fmt)
{ {
int i;
i = 0;
ft_fmt_validate_flag_conv(fmt); ft_fmt_validate_flag_conv(fmt);
ft_fmt_validate_flag_flag(fmt); ft_fmt_validate_flag_flag(fmt);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:48 by jhalford #+# #+# */ /* Created: 2016/11/07 13:33:48 by jhalford #+# #+# */
/* Updated: 2016/12/09 19:07:55 by jhalford ### ########.fr */ /* Updated: 2017/03/05 15:19:49 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -25,9 +25,7 @@ void ft_pad_sharp_o(char *str, t_fmt *fmt)
void ft_pad_sharp_xb(char *str, t_fmt *fmt) void ft_pad_sharp_xb(char *str, t_fmt *fmt)
{ {
char start[3] = {'0',fmt->conversion, 0}; char start[3] = {'0',fmt->conversion, 0};
int i;
i = 0;
if (str[0] == '0') if (str[0] == '0')
{ {
if (str[1] == '0') if (str[1] == '0')

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 18:03:58 by jhalford #+# #+# */ /* Created: 2016/11/03 18:03:58 by jhalford #+# #+# */
/* Updated: 2016/12/07 17:39:37 by jhalford ### ########.fr */ /* Updated: 2017/03/05 15:20:02 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,11 +14,9 @@
char **ft_sstradd(char **sstr, char *new) char **ft_sstradd(char **sstr, char *new)
{ {
int i;
int size; int size;
char **newlist; char **newlist;
i = 0;
size = 0; size = 0;
if (sstr) if (sstr)
while (sstr[size]) while (sstr[size])

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/07 14:25:41 by jhalford #+# #+# */ /* Created: 2016/12/07 14:25:41 by jhalford #+# #+# */
/* Updated: 2017/01/10 10:56:33 by jhalford ### ########.fr */ /* Updated: 2017/03/05 15:20:36 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,9 +15,7 @@
char *ft_strdup(const char *s1) char *ft_strdup(const char *s1)
{ {
char *dup; char *dup;
int i;
i = 0;
if (!s1 || !(dup = (char*)malloc(sizeof(*dup) * (ft_strlen(s1) + 1)))) if (!s1 || !(dup = (char*)malloc(sizeof(*dup) * (ft_strlen(s1) + 1))))
return (NULL); return (NULL);
ft_strcpy(dup, s1); ft_strcpy(dup, s1);

View file

@ -6,12 +6,14 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 18:00:52 by jhalford #+# #+# */ /* Created: 2016/11/03 18:00:52 by jhalford #+# #+# */
/* Updated: 2016/11/25 17:22:07 by jhalford ### ########.fr */ /* Updated: 2017/03/05 15:17:57 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libft.h" #include "libft.h"
#if defined __DARWIN__
int ft_xattr_count(char *path) int ft_xattr_count(char *path)
{ {
ssize_t listlen; ssize_t listlen;
@ -32,3 +34,28 @@ int ft_xattr_count(char *path)
} }
return (count); return (count);
} }
#else
int ft_xattr_count(char *path)
{
ssize_t listlen;
char list[FT_XATTR_SIZE];
int i;
int count;
i = 0;
ft_bzero(list, FT_XATTR_SIZE);
listlen = listxattr(path, list, FT_XATTR_SIZE);
if (listlen == -1)
return (-1);
count = 0;
while (i < listlen)
{
i += ft_strlen(list) + 1;
count++;
}
return (count);
}
#endif

View file

@ -6,12 +6,14 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 18:00:43 by jhalford #+# #+# */ /* Created: 2016/11/03 18:00:43 by jhalford #+# #+# */
/* Updated: 2016/11/03 18:00:44 by jhalford ### ########.fr */ /* Updated: 2017/03/05 15:17:05 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libft.h" #include "libft.h"
#if defined __DARWIN__
int ft_xattr_print(char *path) int ft_xattr_print(char *path)
{ {
ssize_t listlen; ssize_t listlen;
@ -36,3 +38,32 @@ int ft_xattr_print(char *path)
} }
return (0); return (0);
} }
#else
int ft_xattr_print(char *path)
{
ssize_t listlen;
ssize_t valuelen;
char list[FT_XATTR_SIZE];
char value[FT_XATTR_SIZE];
int i;
i = 0;
listlen = listxattr(path, list, FT_XATTR_SIZE);
if (listlen == -1)
return (1);
while (i < listlen)
{
valuelen = getxattr(path, list + i, value,
FT_XATTR_SIZE);
if (valuelen == -1)
ft_printf("couldn't get value\n");
else
ft_printf("%s:\n%s\n", list + i, value);
i += ft_strlen(list) + 1;
}
return (0);
}
#endif