uboot/tools/gdb/error.c
<<
>>
Prefs
   1/*
   2 * (C) Copyright 2000
   3 * Murray Jensen <Murray.Jensen@csiro.au>
   4 *
   5 * SPDX-License-Identifier:     GPL-2.0+
   6 */
   7
   8#include <stdio.h>
   9#include <stdlib.h>
  10#include <string.h>
  11#include <errno.h>
  12#include "error.h"
  13
  14char *pname;
  15
  16void
  17Warning(char *fmt, ...)
  18{
  19    va_list args;
  20
  21    fprintf(stderr, "%s: WARNING: ", pname);
  22
  23    va_start(args, fmt);
  24    vfprintf(stderr, fmt, args);
  25    va_end(args);
  26
  27    fprintf(stderr, "\n");
  28}
  29
  30void
  31Error(char *fmt, ...)
  32{
  33    va_list args;
  34
  35    fprintf(stderr, "%s: ERROR: ", pname);
  36
  37    va_start(args, fmt);
  38    vfprintf(stderr, fmt, args);
  39    va_end(args);
  40
  41    fprintf(stderr, "\n");
  42
  43    exit(1);
  44}
  45
  46void
  47Perror(char *fmt, ...)
  48{
  49    va_list args;
  50    int e = errno;
  51    char *p;
  52
  53    fprintf(stderr, "%s: ERROR: ", pname);
  54
  55    va_start(args, fmt);
  56    vfprintf(stderr, fmt, args);
  57    va_end(args);
  58
  59    if ((p = strerror(e)) == NULL || *p == '\0')
  60        fprintf(stderr, ": Unknown Error (%d)\n", e);
  61    else
  62        fprintf(stderr, ": %s\n", p);
  63
  64    exit(1);
  65}
  66