summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2008-04-30 23:18:21 +0000
committerKen Raeburn <raeburn@mit.edu>2008-04-30 23:18:21 +0000
commitec5b9670de4c7af9ebaecfbd305857ee030460c0 (patch)
treef6bf89e559978a8cea0ee428421ab75dba969381 /src/util
parent4fe69e66b424f10e6a44f8bd488e3fa56682edbf (diff)
After malloc/realloc/calloc failures, return ENOMEM explicitly instead
of reading it from errno. This may make static analysis tools less confused about when we return zero vs nonzero values. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20312 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util')
-rw-r--r--src/util/et/error_message.c4
-rw-r--r--src/util/et/init_et.c4
-rw-r--r--src/util/profile/prof_file.c2
-rw-r--r--src/util/profile/prof_init.c2
-rw-r--r--src/util/profile/profile.swg8
-rw-r--r--src/util/profile/profile_tcl.c6
-rw-r--r--src/util/support/threads.c8
7 files changed, 17 insertions, 17 deletions
diff --git a/src/util/et/error_message.c b/src/util/et/error_message.c
index 6a3a6ccaa..7bd989485 100644
--- a/src/util/et/error_message.c
+++ b/src/util/et/error_message.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1997,2000,2001,2004 by Massachusetts Institute of Technology
+ * Copyright 1997,2000,2001,2004,2008 by Massachusetts Institute of Technology
*
* Copyright 1987, 1988 by MIT Student Information Processing Board
*
@@ -294,7 +294,7 @@ add_error_table(/*@dependent@*/ const struct error_table * et)
del = (struct dynamic_et_list *)malloc(sizeof(struct dynamic_et_list));
if (del == NULL)
- return errno;
+ return ENOMEM;
del->table = et;
diff --git a/src/util/et/init_et.c b/src/util/et/init_et.c
index b0a406403..e397a2706 100644
--- a/src/util/et/init_et.c
+++ b/src/util/et/init_et.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1997 by Massachusetts Institute of Technology
+ * Copyright 1997, 2008 by Massachusetts Institute of Technology
*
* Copyright 1986, 1987, 1988 by MIT Student Information Processing Board
*
@@ -47,7 +47,7 @@ int init_error_table(msgs, base, count)
new_et = (struct foobar *) malloc(sizeof(struct foobar));
if (!new_et)
- return errno; /* oops */
+ return ENOMEM; /* oops */
new_et->etl.table = &new_et->et;
new_et->et.msgs = msgs;
new_et->et.base = base;
diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c
index 44d63a8ba..c6f15fee5 100644
--- a/src/util/profile/prof_file.c
+++ b/src/util/profile/prof_file.c
@@ -228,7 +228,7 @@ errcode_t profile_open_file(const_profile_filespec_t filespec,
expanded_filename = malloc(len);
if (expanded_filename == 0) {
free(prf);
- return errno;
+ return ENOMEM;
}
if (home_env) {
strcpy(expanded_filename, home_env);
diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c
index e5c6f9c8c..9a5659a8c 100644
--- a/src/util/profile/prof_init.c
+++ b/src/util/profile/prof_init.c
@@ -90,7 +90,7 @@ profile_copy(profile_t old_profile, profile_t *new_profile)
COUNT_LINKED_LIST (size, prf_file_t, old_profile->first_file, next);
files = malloc ((size+1) * sizeof(*files));
if (files == NULL)
- return errno;
+ return ENOMEM;
for (i = 0, file = old_profile->first_file; i < size; i++, file = file->next)
files[i] = file->data->filespec;
files[size] = NULL;
diff --git a/src/util/profile/profile.swg b/src/util/profile/profile.swg
index 2e75bb4c6..074a97b9e 100644
--- a/src/util/profile/profile.swg
+++ b/src/util/profile/profile.swg
@@ -1,6 +1,6 @@
%{
/*
- * Copyright 2004 by the Massachusetts Institute of Technology.
+ * Copyright 2004, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
@@ -204,7 +204,7 @@ static errcode_t iter_create(profile_t p, const char **nullterm,
it = malloc(sizeof(*it));
if (it == NULL)
- return errno;
+ return ENOMEM;
{
/* Memory leak!
@@ -218,11 +218,11 @@ static errcode_t iter_create(profile_t p, const char **nullterm,
for (count = 0; nullterm[count]; count++) ;
args = calloc(count+1, sizeof(char *));
if (args == NULL)
- return errno;
+ return ENOMEM;
for (j = 0; j < count; j++) {
args[j] = strdup(nullterm[j]);
if (args[j] == NULL)
- return errno;
+ return ENOMEM;
}
args[j] = NULL;
}
diff --git a/src/util/profile/profile_tcl.c b/src/util/profile/profile_tcl.c
index 31a82f1b4..6a2476e47 100644
--- a/src/util/profile/profile_tcl.c
+++ b/src/util/profile/profile_tcl.c
@@ -1124,7 +1124,7 @@ static errcode_t iter_create(profile_t p, const char **nullterm,
it = malloc(sizeof(*it));
if (it == NULL)
- return errno;
+ return ENOMEM;
{
/* Memory leak!
@@ -1138,11 +1138,11 @@ static errcode_t iter_create(profile_t p, const char **nullterm,
for (count = 0; nullterm[count]; count++) ;
args = calloc(count+1, sizeof(char *));
if (args == NULL)
- return errno;
+ return ENOMEM;
for (j = 0; j < count; j++) {
args[j] = strdup(nullterm[j]);
if (args[j] == NULL)
- return errno;
+ return ENOMEM;
}
args[j] = NULL;
}
diff --git a/src/util/support/threads.c b/src/util/support/threads.c
index 29613fd61..02c14e5de 100644
--- a/src/util/support/threads.c
+++ b/src/util/support/threads.c
@@ -1,7 +1,7 @@
/*
* util/support/threads.c
*
- * Copyright 2004,2005,2006,2007 by the Massachusetts Institute of Technology.
+ * Copyright 2004,2005,2006,2007,2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
@@ -270,7 +270,7 @@ int k5_setspecific (k5_key_t keynum, void *value)
int i;
t = malloc(sizeof(*t));
if (t == NULL)
- return errno;
+ return ENOMEM;
for (i = 0; i < K5_KEY_MAX; i++)
t->values[i] = 0;
/* add to global linked list */
@@ -290,7 +290,7 @@ int k5_setspecific (k5_key_t keynum, void *value)
int i;
t = malloc(sizeof(*t));
if (t == NULL)
- return errno;
+ return ENOMEM;
for (i = 0; i < K5_KEY_MAX; i++)
t->values[i] = 0;
/* add to global linked list */
@@ -624,7 +624,7 @@ krb5int_mutex_alloc (k5_mutex_t **m)
ptr = malloc (sizeof (k5_mutex_t));
if (ptr == NULL)
- return errno;
+ return ENOMEM;
err = k5_mutex_init (ptr);
if (err) {
free (ptr);