Files
Michał Kowalczyk d88e35e1c1 [Pal] Fix error codes in print_error and pal_strerror callsites
These functions (despite documentation comment saying exactly the
opposite) accepted only positive error values, but most of the callsites
passed negative error codes instead. This resulted in Graphene printing
"Unknown error" instead of a proper error details.
2020-12-09 14:32:56 +01:00

69 lines
1.9 KiB
C

/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* Copyright (C) 2014 Stony Brook University */
/*
* This file contains definitions of PAL error codes.
*/
#ifndef PAL_ERROR_H
#define PAL_ERROR_H
#include <stddef.h>
typedef enum _pal_error_t {
PAL_ERROR_SUCCESS = 0,
PAL_ERROR_NOTIMPLEMENTED,
PAL_ERROR_NOTDEFINED,
PAL_ERROR_NOTSUPPORT,
PAL_ERROR_INVAL,
PAL_ERROR_TOOLONG,
PAL_ERROR_DENIED,
PAL_ERROR_BADHANDLE,
PAL_ERROR_STREAMEXIST,
PAL_ERROR_STREAMNOTEXIST,
PAL_ERROR_STREAMISFILE,
PAL_ERROR_STREAMISDIR,
PAL_ERROR_STREAMISDEVICE,
PAL_ERROR_INTERRUPTED,
PAL_ERROR_OVERFLOW,
PAL_ERROR_BADADDR,
PAL_ERROR_NOMEM,
PAL_ERROR_NOTKILLABLE,
PAL_ERROR_INCONSIST,
PAL_ERROR_TRYAGAIN,
PAL_ERROR_ENDOFSTREAM,
PAL_ERROR_NOTSERVER,
PAL_ERROR_NOTCONNECTION,
PAL_ERROR_CONNFAILED,
PAL_ERROR_ADDRNOTEXIST,
PAL_ERROR_AFNOSUPPORT,
PAL_ERROR_CONNFAILED_PIPE,
#define PAL_ERROR_NATIVE_COUNT PAL_ERROR_CONNFAILED_PIPE
#define PAL_ERROR_CRYPTO_START PAL_ERROR_CRYPTO_FEATURE_UNAVAILABLE
/* Crypto error constants and their descriptions are adapted from mbedtls. */
PAL_ERROR_CRYPTO_FEATURE_UNAVAILABLE = 1000,
PAL_ERROR_CRYPTO_INVALID_CONTEXT,
PAL_ERROR_CRYPTO_INVALID_KEY_LENGTH,
PAL_ERROR_CRYPTO_INVALID_INPUT_LENGTH,
PAL_ERROR_CRYPTO_INVALID_OUTPUT_LENGTH,
PAL_ERROR_CRYPTO_BAD_INPUT_DATA,
PAL_ERROR_CRYPTO_INVALID_PADDING,
PAL_ERROR_CRYPTO_DATA_MISALIGNED,
PAL_ERROR_CRYPTO_INVALID_FORMAT,
PAL_ERROR_CRYPTO_AUTH_FAILED,
PAL_ERROR_CRYPTO_IO_ERROR,
PAL_ERROR_CRYPTO_KEY_GEN_FAILED,
PAL_ERROR_CRYPTO_INVALID_KEY,
PAL_ERROR_CRYPTO_VERIFY_FAILED,
PAL_ERROR_CRYPTO_RNG_FAILED,
PAL_ERROR_CRYPTO_INVALID_DH_STATE,
#define PAL_ERROR_CRYPTO_END PAL_ERROR_CRYPTO_INVALID_DH_STATE
} pal_error_t;
/* err - positive value of error code */
const char* pal_strerror(int err);
#endif