summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2017-11-10 09:08:35 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2017-11-10 09:08:35 (GMT)
commit2f1214a79a6befb629466c3e81a993123733a2fe (patch) (side-by-side diff)
treeacf5e1cc9289cf4b655aa873d0b01642090b1391
parent3457c19206858d3e8155dcfc776df8818d05824b (diff)
downloadsmap-2f1214a79a6befb629466c3e81a993123733a2fe.tar.gz
smap-2f1214a79a6befb629466c3e81a993123733a2fe.tar.bz2
Placate cc warnings
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--lib/parseopt.c5
-rw-r--r--lib/sockmapstr.c2
-rw-r--r--lib/stream.c4
-rw-r--r--modules/ldap/ldap.c23
-rw-r--r--src/smapc.c2
-rw-r--r--src/userprivs.c2
6 files changed, 15 insertions, 23 deletions
diff --git a/lib/parseopt.c b/lib/parseopt.c
index cc0c9a6..cf5319d 100644
--- a/lib/parseopt.c
+++ b/lib/parseopt.c
@@ -1,8 +1,8 @@
/* This file is part of Smap.
- Copyright (C) 2008, 2010, 2014 Sergey Poznyakoff
+ Copyright (C) 2008, 2010, 2014, 2017 Sergey Poznyakoff
Smap is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
@@ -17,12 +17,13 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <smap/parseopt.h>
#include <smap/diag.h>
#include <string.h>
+#include <ctype.h>
static struct smap_option const *
find_opt(struct smap_option const *opt, const char *str, const char **value,
int flags)
{
size_t len = strlen(str);
@@ -172,14 +173,12 @@ smap_parseline(struct smap_option const *opt, const char *line, int flags,
int
smap_parseopt(struct smap_option const *opt, int argc, char **argv, int flags,
int *pindex)
{
int i;
- long n;
- char *s;
int rc = 0;
const char *modname = argv[0];
for (i = (flags & SMAP_PARSEOPT_PARSE_ARGV0) ? 0 : 1;
i < argc; i++) {
char *errmsg;
diff --git a/lib/sockmapstr.c b/lib/sockmapstr.c
index 1c0d749..7e188f2 100644
--- a/lib/sockmapstr.c
+++ b/lib/sockmapstr.c
@@ -224,13 +224,13 @@ read_payload_length(struct sockmap_input_stream *sp)
strerror(errno)));
return errno;
}
if (n == 0)
return EOF;
len += n;
- if (p = memchr(sp->nbuf, ':', len)) {
+ if ((p = memchr(sp->nbuf, ':', len))) {
sp->cp = p - sp->nbuf;
sp->nbuf[len] = 0;
sp->nlen = len;
return 0;
}
}
diff --git a/lib/stream.c b/lib/stream.c
index d039c08..c217ca6 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -222,18 +222,18 @@ _stream_flush_buffer(struct _smap_stream *stream, int all)
if (rc)
return rc;
_stream_advance_buffer(stream, size);
}
if (stream->level) {
if (all) {
- if (rc = _force_flush_buffer(stream))
+ if ((rc = _force_flush_buffer(stream)))
return rc;
} else if (BUFFER_FULL_P(stream)) {
if (stream->flags & SMAP_STREAM_EXPBUF)
return _stream_realloc_buffer(stream, 0);
- if (rc = _force_flush_buffer(stream))
+ if ((rc = _force_flush_buffer(stream)))
return rc;
}
}
}
} else if (all)
_stream_advance_buffer(stream, stream->level);
diff --git a/modules/ldap/ldap.c b/modules/ldap/ldap.c
index d686f6b..b34c560 100644
--- a/modules/ldap/ldap.c
+++ b/modules/ldap/ldap.c
@@ -105,13 +105,13 @@ argz_copy(char ***dst, char **a)
return 0;
}
for (n = 0; a[n]; n++)
;
- b = calloc(i + 1, sizeof(b[0]));
+ b = calloc(n + 1, sizeof(b[0]));
if (!b)
return -1;
for (i = 0; i < n; i++) {
b[i] = strdup(a[i]);
if (!b[i])
return -1;
@@ -197,13 +197,13 @@ parse_ldap_conf(const char *name, struct smap_option const *opt)
smap_error("can't open LDAP config file %s: %s",
name, strerror(errno));
return -1;
}
line = 0;
- while (p = fgets(buf, sizeof(buf), fp)) {
+ while ((p = fgets(buf, sizeof(buf), fp))) {
size_t len;
char *errmsg;
++line;
while (*p && isspace(*p))
@@ -251,20 +251,22 @@ parse_ldap_conf(const char *name, struct smap_option const *opt)
}
fclose(fp);
return rc;
}
+#if 0
static int
readconf(struct smap_option const *opt, const char *val, char **errmsg)
{
int rc = parse_ldap_conf(val, opt);
if (rc)
*errmsg = "parse error";
return rc;
}
+#endif
#define MKOPT_DEFAULT 0
#define MKOPT_REUSE 0x01
#define MKOPT_RESET 0x02
static int
@@ -499,14 +501,12 @@ parse_ldap_uri(const char *uri)
static LDAP *
ldap_connect(struct ldap_conf *conf)
{
int rc;
char *ldapuri = NULL;
LDAP *ld = NULL;
- char *val;
- unsigned long lval;
if (ldap_debug_level) {
if (ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL,
&ldap_debug_level)
!= LBER_OPT_SUCCESS )
smap_error("cannot set LBER_OPT_DEBUG_LEVEL %d",
@@ -602,39 +602,37 @@ full_read(int fd, char *file, char *buf, size_t size)
return 0;
}
static int
get_passwd(struct ldap_conf *conf, struct berval *pwd, char **palloc)
{
- char *file;
-
if (conf->bindpwfile) {
struct stat st;
int fd, rc;
char *mem, *p;
- fd = open(file, O_RDONLY);
+ fd = open(conf->bindpwfile, O_RDONLY);
if (fd == -1) {
smap_error("can't open password file %s: %s",
- file, strerror(errno));
+ conf->bindpwfile, strerror(errno));
return -1;
}
if (fstat(fd, &st)) {
smap_error("can't stat password file %s: %s",
- file, strerror(errno));
+ conf->bindpwfile, strerror(errno));
close(fd);
return -1;
}
mem = malloc(st.st_size + 1);
if (!mem) {
smap_error("can't allocate memory (%lu bytes)",
(unsigned long) st.st_size+1);
close(fd);
return -1;
}
- rc = full_read(fd, file, mem, st.st_size);
+ rc = full_read(fd, conf->bindpwfile, mem, st.st_size);
close(fd);
if (rc)
return rc;
mem[st.st_size] = 0;
p = strchr(mem, '\n');
if (p)
@@ -728,13 +726,12 @@ ldap_bind(LDAP *ld, struct ldap_conf *conf)
}
static smap_database_t
mod_ldap_init_db(const char *dbid, int argc, char **argv)
{
- LDAP *ldap;
struct ldap_db *db;
struct ldap_conf conf;
size_t i, j;
struct smap_option *opt;
if (!ldap_conf_cpy(&conf, &dfl_conf))
@@ -877,13 +874,12 @@ getvar(const char *var, size_t len, void *data)
if (strlen(gd->env[i]) == len
&& memcmp(var, gd->env[i], len) == 0)
return strdup(gd->env[i+1]);
}
if (gd->ld) {
- struct berval bv;
char *p;
struct berval **values;
char *attr = malloc(len+1);
if (!attr)
return NULL;
@@ -986,18 +982,15 @@ mod_ldap_query(smap_database_t dbp,
smap_stream_t ostr,
const char *map, const char *key,
struct smap_conninfo const *conninfo)
{
struct ldap_db *db = (struct ldap_db *) dbp;
char const *inenv[5];
- char **env;
- char **attrs;
struct wordsplit ws;
ber_int_t msgid;
int rc;
- char *reply = NULL;
LDAPMessage *res, *msg;
# define __smap_s_cat2__(a,b) a ## b
# define REPLY(d,s) \
((d)->conf.__smap_s_cat2__(s,_reply) \
? (d)->conf.__smap_s_cat2__(s,_reply) \
diff --git a/src/smapc.c b/src/smapc.c
index 88ddb0c..422afcd 100644
--- a/src/smapc.c
+++ b/src/smapc.c
@@ -647,13 +647,13 @@ read_eval_loop(FILE *fp, int interactive)
rl_attempted_completion_function = _command_completion;
read_history(get_history_file_name());
}
#endif
if (interactive && !quiet_startup)
shell_banner();
- while (p = get_input_line(fp, interactive)) {
+ while ((p = get_input_line(fp, interactive))) {
#ifdef WITH_READLINE
if (interactive) {
if (retrieve_history(p))
continue;
add_history(p);
}
diff --git a/src/userprivs.c b/src/userprivs.c
index 46e546f..eb424fe 100644
--- a/src/userprivs.c
+++ b/src/userprivs.c
@@ -67,13 +67,13 @@ get_user_groups(struct privinfo *pi)
pw = getpwuid(pi->uid);
if (!pw)
return;
user = pw->pw_name;
setgrent();
- while (gr = getgrent()) {
+ while ((gr = getgrent())) {
char **p;
for (p = gr->gr_mem; *p; p++)
if (strcmp(*p, user) == 0) {
privinfo_add_grpgid(pi, gr->gr_gid);
break;
}

Return to:

Send suggestions and report system problems to the System administrator.