Skip to content

Commit

Permalink
Use a constant for stackalloc (#68438)
Browse files Browse the repository at this point in the history
  • Loading branch information
vcsjones authored Apr 23, 2022
1 parent e99fb18 commit c5327b2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libraries/Common/src/Interop/Unix/Interop.Errors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,16 @@ internal static ErrorInfo GetLastErrorInfo()

internal static unsafe string StrError(int platformErrno)
{
int maxBufferLength = 1024; // should be long enough for most any UNIX error
byte* buffer = stackalloc byte[maxBufferLength];
byte* message = StrErrorR(platformErrno, buffer, maxBufferLength);
const int MaxBufferLength = 1024; // should be long enough for most any UNIX error
byte* buffer = stackalloc byte[MaxBufferLength];
byte* message = StrErrorR(platformErrno, buffer, MaxBufferLength);

if (message == null)
{
// This means the buffer was not large enough, but still contains
// as much of the error message as possible and is guaranteed to
// be null-terminated. We're not currently resizing/retrying because
// maxBufferLength is large enough in practice, but we could do
// MaxBufferLength is large enough in practice, but we could do
// so here in the future if necessary.
message = buffer;
}
Expand Down

0 comments on commit c5327b2

Please sign in to comment.