Skip to content
Snippets Groups Projects
  • Tom Tromey's avatar
    81aa19c3
    Do not cast away const in agent_run_command · 81aa19c3
    Tom Tromey authored
    
    While investigating something else, I noticed some weird code in
    agent_run_command (use of memcpy rather than strcpy).  Then I noticed
    that 'cmd' is used as both an in and out parameter, despite being
    const.
    
    Casting away const like this is bad.  This patch removes the const and
    fixes the memcpy.  I also added a static assert to assure myself that
    the code in gdbserver is correct -- gdbserver is passing its own
    buffer directly to agent_run_command.
    
    Reviewed-By: default avatarAndrew Burgess <aburgess@redhat.com>
    
    81aa19c3
    History
    Do not cast away const in agent_run_command
    Tom Tromey authored
    
    While investigating something else, I noticed some weird code in
    agent_run_command (use of memcpy rather than strcpy).  Then I noticed
    that 'cmd' is used as both an in and out parameter, despite being
    const.
    
    Casting away const like this is bad.  This patch removes the const and
    fixes the memcpy.  I also added a static assert to assure myself that
    the code in gdbserver is correct -- gdbserver is passing its own
    buffer directly to agent_run_command.
    
    Reviewed-By: default avatarAndrew Burgess <aburgess@redhat.com>