Skip to content

berrno windows issue#959

Merged
arogge merged 4 commits intobareos:masterfrom
alaaeddineelamri:dev/alaaeddineelamri/master/berrno-windows-issue
Nov 12, 2021
Merged

berrno windows issue#959
arogge merged 4 commits intobareos:masterfrom
alaaeddineelamri:dev/alaaeddineelamri/master/berrno-windows-issue

Conversation

@alaaeddineelamri
Copy link
Contributor

@alaaeddineelamri alaaeddineelamri commented Oct 15, 2021

Description

Error messages using berrno do not work properly on windows. This PR fixes the issue.

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

General
  • PR name is meaningful
  • Purpose of the PR is understood
  • Separate commit for this PR in the CHANGELOG.md, PR number referenced is same
  • Commit descriptions are understandable and well formatted
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
  • bareos-check-sources --since-merge does not report any problems
  • git status should not report modifications in the source tree after building and testing
Tests
  • Decision taken that a system- or unittest is required (if not, then remove this paragraph)
  • The decision towards a systemtest is reasonable compared to a unittest
  • Testname matches exactly what is being tested
  • Output of the test leads quickly to the origin of the fault

@pstorz pstorz self-requested a review October 19, 2021 08:04
@pstorz pstorz self-assigned this Oct 19, 2021
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/berrno-windows-issue branch 3 times, most recently from 83b19d2 to 69f2c2c Compare October 20, 2021 15:26
@pstorz pstorz force-pushed the dev/alaaeddineelamri/master/berrno-windows-issue branch from e58ad88 to ac0c062 Compare October 20, 2021 17:17
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/berrno-windows-issue branch from ac0c062 to 6c31b5a Compare October 21, 2021 11:35
@pstorz pstorz requested a review from arogge October 22, 2021 08:53
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a deeper look at all of this and it is really not that easy :(
The BErrNo is supposed to handle errno, Windows Error Codes and BPipe return values. Now on Windows you need to know if the function you just called was a a WinAPI function that sets a Windows Error Code or it was a C runtime function that sets errno.
In fact, to make this work correctly, you'd have to tell BErrNo what kind of error you were expecting, which is what the magic b_errno_win32 was supposed to do.

I guess to make this work, we will have to sit down and discuss our options. Right now I don't see any easy way to make this work reliably.

@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/berrno-windows-issue branch from 6c31b5a to 1ae9b4c Compare October 26, 2021 10:49
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/berrno-windows-issue branch 3 times, most recently from 19baf0b to 16f6733 Compare November 4, 2021 16:57
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/berrno-windows-issue branch from 16f6733 to 10e42d2 Compare November 9, 2021 13:48
@arogge arogge force-pushed the dev/alaaeddineelamri/master/berrno-windows-issue branch 2 times, most recently from c4250c8 to 32abcd2 Compare November 11, 2021 17:29
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result looks fine. I would like to see fewer commits for this. It is probably readonable to make it one for the code changes, one for the unit test and the CHANGELOG.md.
I think we can merge it then.

@arogge arogge force-pushed the dev/alaaeddineelamri/master/berrno-windows-issue branch from 32abcd2 to 9022939 Compare November 11, 2021 17:34
Alaa Eddine Elamri added 4 commits November 12, 2021 10:25
certain windows errors do not have a message to accompany them!
The `formatMessage()` function returns an empty string when called for an error
that does not have a registered message. Basically, not all error strings are defined
in the system message table.
So the change that was made was to make sure that if the error message does not
exist, at least the error code is returned to the user so they can search for the
appropriate error reason somewhere else
The errors would not use the necessary windows code when `b_errno_win32` 
is not set. And so, the program automatically tries to search for a Linux 
interpretation of the error code, which would lead to a wrong/non-existant message
for that error code. Windows and Linux error codes are different and only
have a few common error codes like `0` for `success` or error `2` for `no such file
a directory`.
This change makes sure that, when in doubt, just show both messages and let the user interpret the error code provided.
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/berrno-windows-issue branch from 9022939 to 04db254 Compare November 12, 2021 09:59
@arogge arogge merged commit 4cfdab8 into bareos:master Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants