C2N Emulator GUI client WIP #2

I managed to do some testing around GetCommConfig under Windows 10 and I found out a very odd behavior. If I try to add a call to GetLastError when GetCommConfig fails, then GetCommConfig does not fail any longer:

  /* Configure the port */
  fSuccess = GetCommConfig (hPort, &cfg, &n);
  if (!fSuccess) {
    DWORD e = GetLastError(); // <- Remove this and GetCommConfig fails if a firmware update is requested
    CloseHandle (hPort);
    return FALSE;
  }

As a matter of fact even if I use the code below, the call to GetCommConfig does not fail any longer:

  /* Configure the port */
  fSuccess = GetCommConfig (hPort, &cfg, &n);
  if (!fSuccess) {
    DWORD e = 0; // <- Remove this and GetCommConfig fails if a firmware update is requested
    CloseHandle (hPort);
    return FALSE;
  }

I can also avoid the failure if I add the optimization option -Os when invoking the gcc compiler.

I am entirely baffled by this behavior at the moment 😐

About Luigi Di Fraia

I am a Senior DevOps Engineer so I get to work with the latest technologies and open-source software. However, in my private time I enjoy retro-computing.
This entry was posted in Retrocomputing, Technical and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s