Skip to content

Commit cb277a9

Browse files
committed
Error Codes
1. Rename an error code that was prefixed with WC_ instead of WS_. 2. Add a new error code for missing callbacks. 3. Remove a redundant error code. Channel pending appeared twice. 4. Fix the error code vs string test.
1 parent 66f8a47 commit cb277a9

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/internal.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,6 @@ const char* GetErrorString(int err)
245245
case WS_INVALID_EXTDATA:
246246
return "invalid extended data type";
247247

248-
case WS_CHAN_PENDING:
249-
return "channel open pending";
250-
251248
case WS_SFTP_BAD_REQ_ID:
252249
return "sftp bad request id";
253250

@@ -284,12 +281,15 @@ const char* GetErrorString(int err)
284281
case WS_CHANNEL_NOT_CONF:
285282
return "channel open not confirmed";
286283

287-
case WC_CHANGE_AUTH_E:
284+
case WS_CHANGE_AUTH_E:
288285
return "changing auth type attempt";
289286

290287
case WS_WINDOW_FULL:
291288
return "peer's channel window full";
292289

290+
case WS_MISSING_CALLBACK:
291+
return "missing a callback function";
292+
293293
default:
294294
return "Unknown error code";
295295
}

tests/unit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,13 @@ static int test_Errors(void)
420420
#else
421421
int i, j = 0;
422422
/* Values that are not or no longer error codes. */
423-
int missing[] = { 0 };
423+
int missing[] = { -1059 };
424424
int missingSz = (int)sizeof(missing)/sizeof(missing[0]);
425425

426426
/* Check that all errors have a string and it's the same through the two
427427
* APIs. Check that the values that are not errors map to the unknown
428428
* string. */
429-
for (i = WS_FATAL_ERROR; i >= WS_LAST_E; i--) {
429+
for (i = WS_ERROR; i >= WS_LAST_E; i--) {
430430
errStr = wolfSSH_ErrorToName(i);
431431

432432
if (j < missingSz && i == missing[j]) {

wolfssh/error.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ enum WS_ErrorCodes {
9797
WS_NEXT_ERROR = -1056, /* Getting next value/state is error */
9898
WS_CHAN_RXD = -1057, /* Status that channel data received. */
9999
WS_INVALID_EXTDATA = -1058, /* invalid Channel Extended Data Type */
100-
WS_CHAN_PENDING = -1059, /* peer hasn't confirmed channel open */
101100
WS_SFTP_BAD_REQ_ID = -1060, /* SFTP Bad request ID */
102101
WS_SFTP_BAD_REQ_TYPE = -1061, /* SFTP Bad request ID */
103102
WS_SFTP_STATUS_NOT_OK = -1062, /* SFTP Status not OK */
@@ -110,10 +109,11 @@ enum WS_ErrorCodes {
110109
WS_SSH_NULL_E = -1069, /* SSH was null */
111110
WS_SSH_CTX_NULL_E = -1070, /* SSH_CTX was null */
112111
WS_CHANNEL_NOT_CONF = -1071, /* Channel open not confirmed. */
113-
WC_CHANGE_AUTH_E = -1072, /* Changing auth type attempt */
112+
WS_CHANGE_AUTH_E = -1072, /* Changing auth type attempt */
114113
WS_WINDOW_FULL = -1073,
114+
WS_MISSING_CALLBACK = -1074, /* Callback is missing */
115115

116-
WS_LAST_E = -1073 /* Update this to indicate last error */
116+
WS_LAST_E = -1074 /* Update this to indicate last error */
117117
};
118118

119119

0 commit comments

Comments
 (0)