File: hbaapi2.2.patch

package info (click to toggle)
libhbaapi 2.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 192 kB
  • sloc: makefile: 29; sh: 4
file content (198 lines) | stat: -rw-r--r-- 5,800 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
--- HBAAPILIB.c	2011-11-22 10:56:03.767593438 -0800
+++ HBAAPILIB.c	2011-11-22 11:13:05.468590890 -0800
@@ -37,8 +37,12 @@
  */
 #define HBAAPI_EXPORTS
 #else
+#include <stddef.h>
 #include <dlfcn.h>
+#include <stdlib.h>
 #include <strings.h>
+#include <string.h>
+#define __USE_XOPEN
 #endif
 #include <stdio.h>
 #include <time.h>
@@ -381,7 +385,7 @@
     HBA_ALLADAPTERSCALLBACK_ELEM	**lap;
     HBA_ALLADAPTERSCALLBACK_ELEM	*allcbp;
     HBA_ADAPTERCALLBACK_ELEM		*cbp;
-    HBARemoveCallbackFunc		registeredfunc;
+    HBARemoveCallbackFunc		registeredfunc = NULL;
     HBA_VENDORCALLBACK_ELEM		*vhlp;
     HBA_VENDORCALLBACK_ELEM		*vnext;
     int					found;
@@ -395,7 +399,7 @@
     GRAB_MUTEX(&_hbaapi_APSE_mutex);
     GRAB_MUTEX(&_hbaapi_TE_mutex);
     GRAB_MUTEX(&_hbaapi_LE_mutex);
-    for(listp = cb_lists_array, found = 0; found == 0, *listp != NULL; listp++) {
+    for(listp = cb_lists_array, found = 0; *listp != NULL; listp++) {
 	lastp = *listp;
 	for(cbp=**listp; cbp != NULL; cbp = cbp->next) {
 	    if(cbhandle != (HBA_CALLBACKHANDLE)cbp) {
@@ -455,6 +459,7 @@
     return(status);
 }
 
+#if defined(USESYSLOG) || defined(USELOGFILE)
 static char wwn_str1[17];
 static char wwn_str2[17];
 static char wwn_str3[17];
@@ -471,8 +476,8 @@
     }
     return(buf);
 }
+#endif
 
-
 #ifdef WIN32
 BOOL APIENTRY
 DllMain( HANDLE hModule,
@@ -665,6 +670,7 @@
     char		hbaConfFilePath[256];
     char		*charPtr;
     HBA_LIBRARY_INFO	*lib_infop;
+    int			duplicate = 0;
 
     if(_hbaapi_librarylist != NULL) {
 	fprintf(stderr,
@@ -715,6 +721,30 @@
 	    (strlen(librarypath) == 0)) {
 	    continue;
 	}
+
+	/* Skip over duplicate library entries */
+	duplicate = 0;
+	for(lib_infop = _hbaapi_librarylist;
+	    lib_infop != NULL;
+	    lib_infop = lib_infop->next) {
+		if (strcmp(lib_infop->LibraryName, libraryname) == 0) {
+			fprintf(stderr, "Skipping duplicate entry for Library "
+				"name (%s) in %s\n",
+				libraryname, hbaConfFilePath);
+			duplicate = 1;
+			break;
+		} else if (strcmp(lib_infop->LibraryPath, librarypath) == 0) {
+			fprintf(stderr, "Skipping duplicate entry for Library "
+				"path (%s) in %s\n",
+				librarypath, hbaConfFilePath);
+			duplicate = 1;
+			break;
+		}
+	}
+	/* Duplicate found move to next */
+	if (duplicate)
+		continue;
+
 	/* 
 	 * Special case....
 	 * Look for loglevel
@@ -820,6 +850,9 @@
 	/* successfully loaded library */
 	lib_infop->status = HBA_LIBRARY_LOADED;
     }
+
+    fclose(hbaconf);
+
 #endif /* WIN32 or UNIX */
 #ifdef POSIX_THREADS
     ret = pthread_mutex_init(&_hbaapi_LL_mutex, NULL);
@@ -859,8 +892,15 @@
     InitializeCriticalSection(&_hbaapi_LE_mutex);
 #endif
 
-
-    return HBA_STATUS_OK;
+    /* At least one lib must be loaded */
+    status = HBA_STATUS_ERROR;
+    for(lib_infop = _hbaapi_librarylist; lib_infop != NULL; lib_infop = lib_infop->next) {
+        if (lib_infop->status == HBA_LIBRARY_LOADED) {
+            status = HBA_STATUS_OK;
+            break;
+        }
+    }
+    return status;
 }
 
 HBA_STATUS
@@ -1048,7 +1088,7 @@
 	    if(adapt_infop == NULL) {
 #ifndef WIN32
 		fprintf(stderr,
-			"HBA_GetNumberOfAdapters: calloc failed on sizeof:%d\n",
+			"HBA_GetNumberOfAdapters: calloc failed on sizeof:%ld\n",
 			sizeof(HBA_ADAPTER_INFO));
 #endif
 		RELEASE_MUTEX(&_hbaapi_AL_mutex);
@@ -1359,7 +1399,7 @@
     if(cbp == NULL) {
 #ifndef WIN32
 	fprintf(stderr,
-		"HBA_RegisterForAdapterAddEvents: calloc failed for %d bytes\n",
+		"HBA_RegisterForAdapterAddEvents: calloc failed for %ld bytes\n",
 		sizeof(HBA_ALLADAPTERSCALLBACK_ELEM));
 #endif
 	return HBA_STATUS_ERROR;
@@ -1399,7 +1439,7 @@
 #ifndef WIN32
 	    fprintf(stderr,
 		    "HBA_RegisterForAdapterAddEvents: "
-		    "calloc failed for %d bytes\n",
+		    "calloc failed for %ld bytes\n",
 		    sizeof(HBA_VENDORCALLBACK_ELEM));
 #endif
 	    freevendorhandlelist(vendorhandlelist);
@@ -1535,7 +1575,7 @@
     if(acbp == NULL) {
 #ifndef WIN32
 	fprintf(stderr,
-		"HBA_RegisterForAdapterEvents: calloc failed for %d bytes\n",
+		"HBA_RegisterForAdapterEvents: calloc failed for %ld bytes\n",
 		sizeof(HBA_ADAPTERCALLBACK_ELEM));
 #endif
 	RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
@@ -1627,7 +1667,7 @@
 #ifndef WIN32
 	fprintf(stderr,
 		"HBA_RegisterForAdapterPortEvents: "
-		"calloc failed for %d bytes\n",
+		"calloc failed for %ld bytes\n",
 		sizeof(HBA_ADAPTERCALLBACK_ELEM));
 #endif
 	RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
@@ -1720,7 +1760,7 @@
 #ifndef WIN32
 	fprintf(stderr,
 		"HBA_RegisterForAdapterPortStatEvents: "
-		"calloc failed for %d bytes\n",
+		"calloc failed for %ld bytes\n",
 		sizeof(HBA_ADAPTERCALLBACK_ELEM));
 #endif
 	RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
@@ -1817,7 +1857,7 @@
     if(acbp == NULL) {
 #ifndef WIN32
 	fprintf(stderr,
-		"HBA_RegisterForTargetEvents: calloc failed for %d bytes\n",
+		"HBA_RegisterForTargetEvents: calloc failed for %ld bytes\n",
 		sizeof(HBA_ADAPTERCALLBACK_ELEM));
 #endif
 	RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
@@ -1912,7 +1952,7 @@
     if(acbp == NULL) {
 #ifndef WIN32
 	fprintf(stderr,
-		"HBA_RegisterForLinkEvents: calloc failed for %d bytes\n",
+		"HBA_RegisterForLinkEvents: calloc failed for %ld bytes\n",
 		sizeof(HBA_ADAPTERCALLBACK_ELEM));
 #endif
 	RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
--- ./hbaapi.h	2011-05-19 10:34:37.429915878 -0700
+++ ./hbaapi.h	2011-05-19 10:36:47.658915907 -0700
@@ -234,7 +234,7 @@
 #define HBA_PORTSPEED_1GBIT		1   /* 1 GBit/sec */
 #define HBA_PORTSPEED_2GBIT		2   /* 2 GBit/sec */
 #define HBA_PORTSPEED_10GBIT		4   /* 10 GBit/sec */
-#define HBA_PORTSPEED_NOT_NEGOTIATED	5   /* Speed not established */
+#define HBA_PORTSPEED_NOT_NEGOTIATED	(1 << 15) /* Speed not established */