[lxc-devel] [PATCH 3/3] Remove unused functions

Stéphane Graber stgraber at ubuntu.com
Wed Dec 25 16:15:39 UTC 2013


On Tue, Dec 24, 2013 at 09:08:14PM +0400, Andrey Mazo wrote:
> After 95ee490bbdb97ab2b4f1dfa63a0a26e0dd1c2f17 they are not in public
> API and are not used throughout the lxc codebase.
> This has a bonus of removing workaround for bionic.
> 
> Signed-off-by: Andrey Mazo <mazo at telum.ru>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/parse.c | 48 ------------------------------------------------
>  src/lxc/parse.h |  3 ---
>  src/lxc/utils.c | 25 -------------------------
>  src/lxc/utils.h |  1 -
>  4 files changed, 77 deletions(-)
> 
> diff --git a/src/lxc/parse.c b/src/lxc/parse.c
> index 6c85304..4c9003d 100644
> --- a/src/lxc/parse.c
> +++ b/src/lxc/parse.c
> @@ -33,56 +33,8 @@
>  #include "utils.h"
>  #include <lxc/log.h>
>  
> -/* Workaround for the broken signature of alphasort() in bionic.
> -   This was fixed upstream in 40e467ec668b59be25491bd44bf348a884d6a68d so the
> -   workaround can probably be dropped with the next version of the Android NDK.
> - */
> -#ifdef IS_BIONIC
> -int bionic_alphasort(const struct dirent** a, const struct dirent** b) {
> -       return strcoll((*a)->d_name, (*b)->d_name);
> -}
> -#endif
> -
> -
>  lxc_log_define(lxc_parse, lxc);
>  
> -static int dir_filter(const struct dirent *dirent)
> -{
> -	if (!strcmp(dirent->d_name, ".") ||
> -            !strcmp(dirent->d_name, ".."))
> -                return 0;
> -        return 1;
> -}
> -
> -int lxc_dir_for_each(const char *name, const char *directory,
> -		     lxc_dir_cb callback, void *data)
> -{
> -	struct dirent **namelist;
> -	int n, ret = 0;
> -
> -#ifdef IS_BIONIC
> -	n = scandir(directory, &namelist, dir_filter, bionic_alphasort);
> -#else
> -	n = scandir(directory, &namelist, dir_filter, alphasort);
> -#endif
> -	if (n < 0) {
> -		SYSERROR("failed to scan %s directory", directory);
> -		return -1;
> -	}
> -
> -	while (n--) {
> -		if (!ret &&
> -		    callback(name, directory, namelist[n]->d_name, data)) {
> -			ERROR("callback failed");
> -			ret = -1;
> -		}
> -		free(namelist[n]);
> -	}
> -	free(namelist);
> -
> -	return ret;
> -}
> -
>  int lxc_file_for_each_line(const char *file, lxc_file_cb callback, void *data)
>  {
>  	FILE *f;
> diff --git a/src/lxc/parse.h b/src/lxc/parse.h
> index aead0da..ba7d639 100644
> --- a/src/lxc/parse.h
> +++ b/src/lxc/parse.h
> @@ -28,9 +28,6 @@ typedef int (*lxc_dir_cb)(const char *name, const char *directory,
>  
>  typedef int (*lxc_file_cb)(char *buffer, void *data);
>  
> -extern int lxc_dir_for_each(const char *name, const char *directory,
> -			    lxc_dir_cb callback, void *data);
> -
>  extern int lxc_file_for_each_line(const char *file, lxc_file_cb callback,
>  				  void* data);
>  
> diff --git a/src/lxc/utils.c b/src/lxc/utils.c
> index 40cca57..1f9ceea 100644
> --- a/src/lxc/utils.c
> +++ b/src/lxc/utils.c
> @@ -1031,31 +1031,6 @@ size_t lxc_array_len(void **array)
>  	return result;
>  }
>  
> -void **lxc_dup_array(void **array, lxc_dup_fn element_dup_fn, lxc_free_fn element_free_fn)
> -{
> -	size_t l = lxc_array_len(array);
> -	void **result = calloc(l + 1, sizeof(void *));
> -	void **pp;
> -	void *p;
> -	int saved_errno = 0;
> -
> -	if (!result)
> -		return NULL;
> -
> -	for (l = 0, pp = array; pp && *pp; pp++, l++) {
> -		p = element_dup_fn(*pp);
> -		if (!p) {
> -			saved_errno = errno;
> -			lxc_free_array(result, element_free_fn);
> -			errno = saved_errno;
> -			return NULL;
> -		}
> -		result[l] = p;
> -	}
> -
> -	return result;
> -}
> -
>  int lxc_write_to_file(const char *filename, const void* buf, size_t count, bool add_newline)
>  {
>  	int fd, saved_errno;
> diff --git a/src/lxc/utils.h b/src/lxc/utils.h
> index 86ebe3a..01a5a82 100644
> --- a/src/lxc/utils.h
> +++ b/src/lxc/utils.h
> @@ -262,7 +262,6 @@ typedef void *(*lxc_dup_fn)(void *);
>  extern int lxc_grow_array(void ***array, size_t* capacity, size_t new_size, size_t capacity_increment);
>  extern void lxc_free_array(void **array, lxc_free_fn element_free_fn);
>  extern size_t lxc_array_len(void **array);
> -extern void **lxc_dup_array(void **array, lxc_dup_fn element_dup_fn, lxc_free_fn element_free_fn);
>  
>  extern void **lxc_append_null_to_array(void **array, size_t count);
>  
> -- 
> 1.8.4.5
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20131225/1176db6e/attachment.pgp>


More information about the lxc-devel mailing list