Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/altq simplify priq_class_create(): if the alloc for cl_...
details: https://anonhg.NetBSD.org/src/rev/fcf04b151e97
branches: trunk
changeset: 362542:fcf04b151e97
user: mrg <mrg%NetBSD.org@localhost>
date: Fri Jun 15 08:34:18 2018 +0000
description:
simplify priq_class_create(): if the alloc for cl_q fails,
then only clean up required to to free cl. delete all the
code at err_ret that was probably used in the past, and move
the free + return upon failure earlier.
diffstat:
sys/altq/altq_priq.c | 26 ++++++--------------------
1 files changed, 6 insertions(+), 20 deletions(-)
diffs (54 lines):
diff -r 930275ebf403 -r fcf04b151e97 sys/altq/altq_priq.c
--- a/sys/altq/altq_priq.c Fri Jun 15 08:17:38 2018 +0000
+++ b/sys/altq/altq_priq.c Fri Jun 15 08:34:18 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: altq_priq.c,v 1.24 2017/07/28 13:53:17 riastradh Exp $ */
+/* $NetBSD: altq_priq.c,v 1.25 2018/06/15 08:34:18 mrg Exp $ */
/* $KAME: altq_priq.c,v 1.13 2005/04/13 03:44:25 suz Exp $ */
/*
* Copyright (C) 2000-2003
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.24 2017/07/28 13:53:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.25 2018/06/15 08:34:18 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_altq.h"
@@ -317,8 +317,10 @@
cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF,
M_WAITOK|M_ZERO);
- if (cl->cl_q == NULL)
- goto err_ret;
+ if (cl->cl_q == NULL) {
+ free(cl, M_DEVBUF);
+ return (NULL);
+ }
}
pif->pif_classes[pri] = cl;
@@ -372,22 +374,6 @@
#endif /* ALTQ_RED */
return (cl);
-
- err_ret:
- if (cl->cl_red != NULL) {
-#ifdef ALTQ_RIO
- if (q_is_rio(cl->cl_q))
- rio_destroy((rio_t *)cl->cl_red);
-#endif
-#ifdef ALTQ_RED
- if (q_is_red(cl->cl_q))
- red_destroy(cl->cl_red);
-#endif
- }
- if (cl->cl_q != NULL)
- free(cl->cl_q, M_DEVBUF);
- free(cl, M_DEVBUF);
- return (NULL);
}
static int
Home |
Main Index |
Thread Index |
Old Index