Fix multiple instances of the following clang 3.6.0 warning in ppp:

usr.sbin/ppp/command.c:2054:74: error: address of array 'arg->bundle->radius.cfg.file'
will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
      if (arg->bundle->radius.alive.interval && !arg->bundle->radius.cfg.file) {
                                                ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~

In all cases, the file field of struct radius is a char array, but the
intent was to check whether the string is empty, so add an indirection
to achieve that.  Use a similar approach for the sockname field of
struct server.
This commit is contained in:
Dimitry Andric 2015-01-28 21:33:49 +00:00
parent 3f7acdfe6e
commit 9304cfd07c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=277857
5 changed files with 8 additions and 8 deletions

View File

@ -2051,7 +2051,7 @@ SetVariable(struct cmdargs const *arg)
res = 1;
} else {
arg->bundle->radius.alive.interval = atoi(argp);
if (arg->bundle->radius.alive.interval && !arg->bundle->radius.cfg.file) {
if (arg->bundle->radius.alive.interval && !*arg->bundle->radius.cfg.file) {
log_Printf(LogWARN, "rad_alive requires radius to be configured\n");
res = 1;
} else if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED) {
@ -2335,7 +2335,7 @@ SetVariable(struct cmdargs const *arg)
res = 1;
}
if (arg->bundle->radius.port_id_type && !arg->bundle->radius.cfg.file) {
if (arg->bundle->radius.port_id_type && !*arg->bundle->radius.cfg.file) {
log_Printf(LogWARN, "rad_port_id requires radius to be configured\n");
res = 1;
}

View File

@ -880,7 +880,7 @@ IpcpLayerDown(struct fsm *fp)
radius_Account(&fp->bundle->radius, &fp->bundle->radacct,
fp->bundle->links, RAD_STOP, &ipcp->throughput);
if (fp->bundle->radius.cfg.file && fp->bundle->radius.filterid)
if (*fp->bundle->radius.cfg.file && fp->bundle->radius.filterid)
system_Select(fp->bundle, fp->bundle->radius.filterid, LINKDOWNFILE,
NULL, NULL);
radius_StopTimer(&fp->bundle->radius);
@ -949,7 +949,7 @@ IpcpLayerUp(struct fsm *fp)
radius_Account(&fp->bundle->radius, &fp->bundle->radacct, fp->bundle->links,
RAD_START, &ipcp->throughput);
if (fp->bundle->radius.cfg.file && fp->bundle->radius.filterid)
if (*fp->bundle->radius.cfg.file && fp->bundle->radius.filterid)
system_Select(fp->bundle, fp->bundle->radius.filterid, LINKUPFILE,
NULL, NULL);
radius_StartTimer(fp->bundle);

View File

@ -486,7 +486,7 @@ ipv6cp_LayerUp(struct fsm *fp)
* evaluated.
*/
if (!Enabled(fp->bundle, OPT_IPCP)) {
if (fp->bundle->radius.cfg.file && fp->bundle->radius.filterid)
if (*fp->bundle->radius.cfg.file && fp->bundle->radius.filterid)
system_Select(fp->bundle, fp->bundle->radius.filterid, LINKUPFILE,
NULL, NULL);
}
@ -539,7 +539,7 @@ ipv6cp_LayerDown(struct fsm *fp)
* evaluated.
*/
if (!Enabled(fp->bundle, OPT_IPCP)) {
if (fp->bundle->radius.cfg.file && fp->bundle->radius.filterid)
if (*fp->bundle->radius.cfg.file && fp->bundle->radius.filterid)
system_Select(fp->bundle, fp->bundle->radius.filterid, LINKDOWNFILE,
NULL, NULL);
}

View File

@ -1345,7 +1345,7 @@ radius_alive(void *v)
void
radius_StartTimer(struct bundle *bundle)
{
if (bundle->radius.cfg.file && bundle->radius.alive.interval) {
if (*bundle->radius.cfg.file && bundle->radius.alive.interval) {
bundle->radius.alive.timer.func = radius_alive;
bundle->radius.alive.timer.name = "radius alive";
bundle->radius.alive.timer.load = bundle->radius.alive.interval * SECTICKS;

View File

@ -248,7 +248,7 @@ server_LocalOpen(struct bundle *bundle, const char *name, mode_t mask)
oldmask = (mode_t)-1; /* Silence compiler */
if (server.cfg.sockname && !strcmp(server.cfg.sockname, name))
if (server.cfg.sockname[0] != '\0' && !strcmp(server.cfg.sockname, name))
server_Close(bundle);
memset(&ifsun, '\0', sizeof ifsun);