nsswitch: Move nss_err_str to its only caller
[ira/wip.git] / libcli / util / ntstatus.h
index dd1a0d0db0fa4c64465ae3dfd757fde91ed05543..c60e424f68ac96bd56bdabd5126c8c0ebcdc140c 100644 (file)
@@ -605,6 +605,8 @@ typedef uint32_t NTSTATUS;
 #define NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x20004)
 #define NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX NT_STATUS(0xC0000000 | 0x20026)
 #define NT_STATUS_RPC_NT_CALL_FAILED NT_STATUS(0xC0000000 | 0x2001B)
+#define NT_STATUS_RPC_NT_PROTOCOL_ERROR NT_STATUS(0xC0000000 | 0x2001D)
+#define NT_STATUS_RPC_NT_PROCNUM_OUT_OF_RANGE NT_STATUS(0xC0000000 | 0x2002E)
 #define NT_STATUS_ERROR_DS_OBJ_STRING_NAME_EXISTS NT_STATUS(0xC0000000 | 0x2071)
 #define NT_STATUS_ERROR_DS_INCOMPATIBLE_VERSION NT_STATUS(0xC0000000 | 0x00002177)
 
@@ -635,8 +637,16 @@ NTSTATUS nt_status_string_to_code(const char *nt_status_str);
 /** Used by ntstatus_dos_equal: */
 extern bool ntstatus_check_dos_mapping;
 
-#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
-#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
+/* we need these here for openchange */
+#ifndef likely
+#define likely(x) (x)
+#endif
+#ifndef unlikely
+#define unlikely(x) (x)
+#endif
+
+#define NT_STATUS_IS_OK(x) (likely(NT_STATUS_V(x) == 0))
+#define NT_STATUS_IS_ERR(x) (unlikely((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000))
 /* checking for DOS error mapping here is ugly, but unfortunately the
    alternative is a very intrusive rewrite of the torture code */
 #if _SAMBA_BUILD_ == 4
@@ -646,7 +656,7 @@ extern bool ntstatus_check_dos_mapping;
 #endif
 
 #define NT_STATUS_HAVE_NO_MEMORY(x) do { \
-       if (!(x)) {\
+       if (unlikely(!(x))) {           \
                return NT_STATUS_NO_MEMORY;\
        }\
 } while (0)
@@ -672,6 +682,13 @@ extern bool ntstatus_check_dos_mapping;
        }\
 } while (0)
 
+#define NT_STATUS_NOT_OK_RETURN_AND_FREE(x, ctx) do {  \
+       if (!NT_STATUS_IS_OK(x)) {\
+               talloc_free(ctx); \
+               return x;\
+       }\
+} while (0)
+
 #define NT_STATUS_IS_ERR_RETURN(x) do { \
        if (NT_STATUS_IS_ERR(x)) {\
                return x;\