IsError v0.1.0

Source
Tests whether a raw syscall result is an error.

Package: Bsd

Signature

func IsError(result: int64) -> bool;

Parameters

NameTypeDescription
resultint64Raw syscall return value.

Returns

bool - true when result is a negative errno in the range -1 through -4095; otherwise false.

The wrappers report failure as a small negative value, so a non-negative result — a byte count, a process ID, a mapped address, or 0 — is always a success. IsError therefore never misclassifies a legitimate result.

Example

import Bsd::{ IsError, Mmap, MapAnonymous, MapPrivate, ProtectionRead, ProtectionWrite };

func Main() -> int {
    let result = Mmap(null, 4096u, ProtectionRead | ProtectionWrite,
        MapPrivate | MapAnonymous, -1i32, 0u64);
    if IsError(result) {
        return 1;
    }
    return 0;
}

See also