Skip to content

Commit

Permalink
Remove unused functions
Browse files Browse the repository at this point in the history
After 95ee490 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@telum.ru>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
  • Loading branch information
Andrey Mazo authored and stgraber committed Dec 25, 2013
1 parent 579e783 commit aa5233a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 77 deletions.
48 changes: 0 additions & 48 deletions src/lxc/parse.c
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions src/lxc/parse.h
Expand Up @@ -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);

Expand Down
25 changes: 0 additions & 25 deletions src/lxc/utils.c
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/lxc/utils.h
Expand Up @@ -263,7 +263,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);

Expand Down

0 comments on commit aa5233a

Please sign in to comment.