Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lightware_laser_serial: fix pointer for enabling serial mode #21747

Merged
merged 1 commit into from
Jun 21, 2023

Commits on Jun 21, 2023

  1. lightware_lase_serial: fix pointer for enabling serial mode

    const char *data = "www\r\n";
    Defines a cstring of 6 bytes: 'w', 'w', 'w', '\r', '\n', '\0'
    
    type of data: char const*
    type of &data: char const**
    
    So when we call
    write(_fd, &data, strlen(data));
    then strlen(data) == 5
    and we send the 4 byte memory address of data
    + some additional random byte.
    
    Correct is
    write(_fd, data, strlen(data));
    where char const* gets casted to const void * and we pass
    the pointer to the content of data.
    
    The fundamental problem here is write() not being typesafe.
    MaEtUgR committed Jun 21, 2023
    Configuration menu
    Copy the full SHA
    7c384ac View commit details
    Browse the repository at this point in the history