(void)strncat(retval, sub, sub_size);
(void)strncat(retval, str_end + 1, second_half);
- if ((str_start = strstr(retval, str)) != NULL) {
+ if (strstr(retval, str) != NULL) {
/*
* If there is another occurrences of str call this function
* recursively.
* each of the replace attempt will fail and we'll move on to the
* next char.
*/
- tmp = strdup(str);
+ tmp = xstrdup(str);
for (pos = str; *pos != '\0'; pos++) {
if (*pos != '$') {
continue;
}
else {
retval = tmp2;
- if (tmp != NULL) {
- XFREE(tmp);
- }
+ XFREE(tmp);
}
return retval;
* Try to convert any variable substitutions. If this function
* returns a new string one or more var subs where expanded.
*/
- else if ((sub = sun_expand2amd(out)) != NULL) {
+ else if (out != NULL && (sub = sun_expand2amd(out)) != NULL) {
out = sub;
}
if (out != NULL) {
xstrlcat(dest, out, destlen);
}
- if (sub != NULL) {
- XFREE(sub);
- }
- if (sub2 != NULL) {
- XFREE(sub2);
- }
+ XFREE(sub);
+ XFREE(sub2);
}
if (s_entry->mountpt_list != NULL) {
/* multi-mount point */
sun_multi2amd(line_buff, sizeof(line_buff), key, s_entry);
- retval = strdup(line_buff);
+ retval = xstrdup(line_buff);
}
else {
/* single mount point */
if (NSTREQ(s_entry->fstype, SUN_NFS_TYPE, strlen(SUN_NFS_TYPE))) {
/* NFS Type */
sun_nfs2amd(line_buff, sizeof(line_buff), key, s_entry);
- retval = strdup(line_buff);
+ retval = xstrdup(line_buff);
}
else if (NSTREQ(s_entry->fstype, SUN_HSFS_TYPE, strlen(SUN_HSFS_TYPE))) {
/* HSFS Type (CD fs) */
sun_hsfs2amd(line_buff, sizeof(line_buff), key, s_entry);
- retval = strdup(line_buff);
+ retval = xstrdup(line_buff);
}
/*
* XXX: The following fstypes are not yet supported.
else {
plog(XLOG_INFO, "No SUN fstype specified defaulting to NFS.");
sun_nfs2amd(line_buff, sizeof(line_buff), key, s_entry);
- retval = strdup(line_buff);
+ retval = xstrdup(line_buff);
}
}
err:
- if (s_entry != NULL) {
- XFREE(s_entry);
- }
+ XFREE(s_entry);
return retval;
}