[openib-general] [PATCH] Optimize check_class_table and method_table to return BOOL.
Krishna Kumar
krkumar at us.ibm.com
Tue Nov 2 10:40:04 PST 2004
The callers are just interested in knowing whether any methods or method
tables are in use, not the actual use count.
Thanks,
- KK
diff -ruNp 1/mad.c 2/mad.c
--- 1/mad.c 2004-11-02 10:32:51.000000000 -0800
+++ 2/mad.c 2004-11-02 10:35:01.000000000 -0800
@@ -530,34 +530,30 @@ static int allocate_method_table(struct
return 0;
}
+/*
+ * Check to see if there are any methods still in use.
+ */
static int check_method_table(struct ib_mad_mgmt_method_table *method)
{
- int i, j;
+ int i;
- /* Check to see if there are any methods still in use */
- j = 0;
- for (i = 0; i < IB_MGMT_MAX_METHODS; i++) {
+ for (i = 0; i < IB_MGMT_MAX_METHODS; i++)
if (method->agent[i])
- j++;
- }
- return j;
+ return 1;
+ return 0;
}
+/*
+ * Check to see if there are any method tables for this class still in use.
+ */
static int check_class_table(struct ib_mad_mgmt_class_table *class)
{
- int i, j;
+ int i;
- /*
- * Check to see if there are any method tables for this class still
- * in use
- */
- j = 0;
- for (i = 0; i < MAX_MGMT_CLASS; i++) {
- if (class->method_table[i]) {
- j++;
- }
- }
- return j;
+ for (i = 0; i < MAX_MGMT_CLASS; i++)
+ if (class->method_table[i])
+ return 1;
+ return 0;
}
static void remove_methods_mad_agent(struct ib_mad_mgmt_method_table *method,
More information about the general
mailing list