From 8d7c88667190fe286971ac4fffb64ee5bd9eeeb0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Oct 2005 03:24:00 +0000 Subject: r11137: Compile with only 2 warnings (I'm still working on that code) on a gcc4 x86_64 box. Jeremy. (This used to be commit d720867a788c735e56d53d63265255830ec21208) --- source3/lib/clobber.c | 2 + source3/lib/iconv.c | 16 +++---- source3/lib/privileges.c | 2 +- source3/lib/system_smbd.c | 105 ++++++++++++++++++++++++++++++++++------------ source3/lib/util.c | 14 +++---- source3/lib/util_getent.c | 45 -------------------- source3/lib/util_sid.c | 11 +++-- 7 files changed, 101 insertions(+), 94 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/clobber.c b/source3/lib/clobber.c index fb3a0dc281..f39b94538e 100644 --- a/source3/lib/clobber.c +++ b/source3/lib/clobber.c @@ -54,7 +54,9 @@ void clobber_region(const char *fn, unsigned int line, char *dest, size_t len) * (This is not redundant with the clobbering above. The * marking might not actually take effect if we're not running * under valgrind.) */ +#if 0 VALGRIND_MAKE_WRITABLE(dest, len); +#endif #endif /* VALGRIND */ #endif /* DEVELOPER */ } diff --git a/source3/lib/iconv.c b/source3/lib/iconv.c index d58165fed0..f738f45efa 100644 --- a/source3/lib/iconv.c +++ b/source3/lib/iconv.c @@ -642,15 +642,15 @@ static size_t utf8_pull(void *cd, const char **inbuf, size_t *inbytesleft, *inbytesleft = in_left; *outbytesleft = out_left; - *inbuf = c; - *outbuf = uc; + *inbuf = (char *)c; + *outbuf = (char *)uc; return 0; error: *inbytesleft = in_left; *outbytesleft = out_left; - *inbuf = c; - *outbuf = uc; + *inbuf = (char *)c; + *outbuf = (char *)uc; return -1; } @@ -755,16 +755,16 @@ static size_t utf8_push(void *cd, const char **inbuf, size_t *inbytesleft, *inbytesleft = in_left; *outbytesleft = out_left; - *inbuf = uc; - *outbuf = c; + *inbuf = (char *)uc; + *outbuf = (char *)c; return 0; error: *inbytesleft = in_left; *outbytesleft = out_left; - *inbuf = uc; - *outbuf = c; + *inbuf = (char *)uc; + *outbuf = (char *)c; return -1; } diff --git a/source3/lib/privileges.c b/source3/lib/privileges.c index ff0631b82f..ee69613df0 100644 --- a/source3/lib/privileges.c +++ b/source3/lib/privileges.c @@ -104,7 +104,7 @@ PRIVS privs[] = { }; typedef struct { - int count; + size_t count; DOM_SID *list; } SID_LIST; diff --git a/source3/lib/system_smbd.c b/source3/lib/system_smbd.c index f124983006..1afd44b709 100644 --- a/source3/lib/system_smbd.c +++ b/source3/lib/system_smbd.c @@ -27,15 +27,58 @@ #include "includes.h" #ifndef HAVE_GETGROUPLIST + +static int int_compare( int *a, int *b ) +{ + if ( *a == *b ) + return 0; + else if ( *a < *b ) + return -1; + else + return 1; +} + +void remove_duplicate_gids( int *num_groups, gid_t *groups ) +{ + int i; + int count = *num_groups; + + if ( *num_groups <= 0 || !groups ) + return; + + DEBUG(8,("remove_duplicate_gids: Enter %d gids\n", *num_groups)); + + qsort( groups, *num_groups, sizeof(gid_t), QSORT_CAST int_compare ); + + for ( i=1; i *grpcnt) { *grpcnt = num_gids + 1; ret = -1; } else { ret = getgroups(*grpcnt - 1, &groups[1]); - if (ret >= 0) { - groups[0] = gid; - *grpcnt = ret + 1; + if (ret < 0) { + SAFE_FREE(gids_saved); + /* very strange! */ + return -1; } - - /* remove any duplicates gids in the list */ + groups[0] = gid; + *grpcnt = ret + 1; + /* remove any duplicates gids in the list */ remove_duplicate_gids( grpcnt, groups ); } @@ -103,7 +154,7 @@ static int getgrouplist_internals(const char *user, gid_t gid, gid_t *groups, in free(gids_saved); return -1; } - + free(gids_saved); return ret; } @@ -140,9 +191,10 @@ static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grp } BOOL getgroups_user(const char *user, gid_t primary_gid, - gid_t **ret_groups, int *ngroups) + gid_t **ret_groups, size_t *p_ngroups) { - int ngrp, max_grp; + size_t ngrp; + int max_grp; gid_t *temp_groups; gid_t *groups; int i; @@ -154,9 +206,8 @@ BOOL getgroups_user(const char *user, gid_t primary_gid, } if (sys_getgrouplist(user, primary_gid, temp_groups, &max_grp) == -1) { - gid_t *groups_tmp; - + groups_tmp = SMB_REALLOC_ARRAY(temp_groups, gid_t, max_grp); if (!groups_tmp) { @@ -183,7 +234,7 @@ BOOL getgroups_user(const char *user, gid_t primary_gid, for (i=0; i 0) { - dump_data(11, data, len); + dump_data(11, (const char *)data, len); } #endif } diff --git a/source3/lib/util_getent.c b/source3/lib/util_getent.c index 1b01cae5fa..475b0da87b 100644 --- a/source3/lib/util_getent.c +++ b/source3/lib/util_getent.c @@ -304,48 +304,3 @@ void free_userlist(struct sys_userlist *list_head) SAFE_FREE(old_head); } } - -/**************************************************************** -****************************************************************/ - -static int int_compare( int *a, int *b ) -{ - if ( *a == *b ) - return 0; - else if ( *a < *b ) - return -1; - else - return 1; -} - -void remove_duplicate_gids( int *num_groups, gid_t *groups ) -{ - int i; - int count = *num_groups; - - if ( *num_groups <= 0 || !groups ) - return; - - - DEBUG(8,("remove_duplicate_gids: Enter %d gids\n", *num_groups)); - - qsort( groups, *num_groups, sizeof(gid_t), QSORT_CAST int_compare ); - - for ( i=1; i