Skip to content

Commit

Permalink
Quiet compile warnings in iotrace.c
Browse files Browse the repository at this point in the history
GCC complained about assignment of const char *optarg to char *flags,
and rightly so. It is better practice to copy SPANK options into the
plugin using them, so this fix implements that in order to suppress
the compiler warning.
  • Loading branch information
grondo committed Dec 16, 2009
1 parent 4be18e5 commit 6f9f672
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions iotrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SPANK_PLUGIN(iotrace, 1)
#define IOTRACE_ENABLE 1

static int enabled = 0;
static char *flags = "";
static char *flags = NULL;

static int _opt_process (int val, const char *optarg, int remote);

Expand Down Expand Up @@ -80,6 +80,7 @@ int slurm_spank_task_init (spank_t sp, int ac, char **av)
char nbuf [4096], obuf [4096];
char label [64];
const char *preload = "libplasticfs.so";
const char *lflags = flags ? flags : "";

if (!enabled)
return (0);
Expand All @@ -94,8 +95,9 @@ int slurm_spank_task_init (spank_t sp, int ac, char **av)

/* prepend to PLASTICFS (with a pipe) */
_iotrace_label (sp, label, sizeof (label));
if (spank_getenv (sp, "PLASTICFS", obuf, sizeof (obuf)) == ESPANK_SUCCESS)
snprintf (nbuf, sizeof (nbuf), "log - %s %s | %s", label, flags, obuf);
if (spank_getenv (sp, "PLASTICFS", obuf, sizeof (obuf)) == ESPANK_SUCCESS)
snprintf (nbuf, sizeof (nbuf), "log - %s %s | %s",
label, lflags, obuf);
else
snprintf (nbuf, sizeof (nbuf), "log - %s %s", label, flags);

Expand All @@ -111,7 +113,7 @@ static int _opt_process (int val, const char *optarg, int remote)
case IOTRACE_ENABLE:
enabled = 1;
if (optarg)
flags = optarg;
flags = strdup (optarg);
break;
default:
slurm_error ("Ignoring unknown iotrace option value %d\n", val);
Expand All @@ -121,6 +123,13 @@ static int _opt_process (int val, const char *optarg, int remote)
return (0);
}

int slurm_spank_exit (spank_t sp, int ac, char **av)
{
if (flags)
free (flags);
return (0);
}

/*
* vi: ts=4 sw=4 expandtab
*/

0 comments on commit 6f9f672

Please sign in to comment.