[torqueusers] Bug in lib/Libcmds/set_attr.c

Prakash Velayutham velayups at email.uc.edu
Thu Jul 28 10:52:05 MDT 2005


Hi,

There is a (rather trivial) bug in the lib/Libcmds/set_attr.c file. I am 
attaching the source below with the bug underlined. The variable should 
be attr->value but it is attr->name. Could someone get this corrected in 
the CVS.

#include <pbs_config.h>   /* the master config generated by configure */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "pbs_ifl.h"

void set_attr(
  struct attrl **attrib,
  char *attrib_name,
  char *attrib_value)
  {
  struct attrl *attr, *ap;
  attr = (struct attrl *) malloc(sizeof(struct attrl));
  if (attr == NULL)
    {
    fprintf(stderr, "Out of memory\n");
    exit(2);
    }
  if (attrib_name == NULL)
    {
    attr->name = NULL;
    }
  else
    {
    attr->name = (char *)malloc(strlen(attrib_name) + 1);
    if (attr->name == NULL)
      {
      fprintf(stderr, "Out of memory\n");
      exit(2);
      }
    strcpy(attr->name,attrib_name);
    }
  attr->resource = NULL;
  if (attrib_value == NULL)
    {
    attr->value = NULL;
    }
  else
    {
    attr->value = (char *)malloc(strlen(attrib_value) + 1);
    if (*_attr->name_* == NULL)
      {
      fprintf(stderr, "Out of memory\n");
      exit(2);
      }
    strcpy(attr->value,attrib_value);
    }
  attr->next = NULL;
  if (*attrib == NULL)
    {
    *attrib = attr;
    }
  else
    {
    ap = *attrib;
    while (ap->next != NULL)
      ap = ap->next;
    ap->next = attr;
    }
  return;
  }  /* END set_attr() */

Regards,
Prakash


More information about the torqueusers mailing list