Skip to content

goto-instrument: diverse problems with the signal.h API #973

Closed
@stahlbauer

Description

@stahlbauer

Producing code from goto-files that reference signal.h causes several problems.

Example program:

#include<signal.h>
#include<stdlib.h>

void sig_block(int sig)                                               
{                                                                               
    sigset_t ss;                                                                
    sigemptyset(&ss);                                                           
    sigaddset(&ss, sig);                                                        
    sigprocmask(SIG_BLOCK, &ss, NULL);                                          
}  

int main() {
    sig_block(0);
    return 0;
}

Resulting C file (produced with goto-instrument):

#include <signal.h>

#ifndef NULL
#define NULL ((void*)0)
#endif

// sig_block
// file example_typedef_sigset.c line 4
void sig_block(signed int sig);

signed int main()
{
  sig_block(0);
  return 0;
}

void sig_block(signed int sig)
{
  struct anonymous ss;
  sigemptyset(&ss);
  sigaddset(&ss, sig);
  sigprocmask(0, &ss, ((sigset_t *)NULL));
}

Especially the translation of sigset_t ss; to struct anonymous ss; seems to be critical (the struct anonymous is declared/defined nowhere).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions