[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] [PATCH] restore terminal and print backtrace for segfau

From: Mike Frysinger
Subject: Re: [Nano-devel] [PATCH] restore terminal and print backtrace for segfaults and assertions
Date: Tue, 16 Jan 2018 02:41:39 -0500

On 15 Jan 2018 03:48, Brand Huntsman wrote:
> On Mon, 15 Jan 2018 04:26:23 -0500 Mike Frysinger wrote:
> > shouldn't clobber the standard assert macro ...
> No clobbering, I removed assert.h :)

there isn't a strong guarantee that it won't be included by system or
library headers, so that isn't sufficient

> +static void segfault_handler(int nothing)
> +{
> +     endwin();
> +     tcsetattr(0, TCSANOW, &oldterm);
> +     #define SEG_FAULT "Segmentation fault\n"

you should never indent CPP macros.  the # must be in col 0.

that said this should really be written like:
  static const char msg[] = "...";

then you can use sizeof() instead of strlen().

> +     if(write(2, SEG_FAULT, strlen(SEG_FAULT)));

style is incorrect.  it also lacks information as to why you're
writing it this way.  i'm guessing it's due to WUR, so you'd want

  if (write(...)) {
    /* Silence unused result warning. */

Attachment: signature.asc
Description: Digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]