mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: replace sprintf with snprintf (MacOS), add note about vfork
This commit is contained in:
committed by
Mark Olesen
parent
ffbd05f72a
commit
83b1ebee6f
@ -7,7 +7,7 @@
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2011 Symscape
|
Copyright (C) 2011 Symscape
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -998,14 +998,14 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
|
|||||||
if (exists(src, false))
|
if (exists(src, false))
|
||||||
{
|
{
|
||||||
constexpr const int maxIndex = 99;
|
constexpr const int maxIndex = 99;
|
||||||
char index[3];
|
char index[4];
|
||||||
|
|
||||||
for (int n = 0; n <= maxIndex; ++n)
|
for (int n = 0; n <= maxIndex; ++n)
|
||||||
{
|
{
|
||||||
fileName dstName(src + "." + ext);
|
fileName dstName(src + "." + ext);
|
||||||
if (n)
|
if (n)
|
||||||
{
|
{
|
||||||
sprintf(index, "%02d", n);
|
::snprintf(index, 4, "%02d", n);
|
||||||
dstName += index;
|
dstName += index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -1305,14 +1305,14 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
|
|||||||
if (exists(src, false))
|
if (exists(src, false))
|
||||||
{
|
{
|
||||||
constexpr const int maxIndex = 99;
|
constexpr const int maxIndex = 99;
|
||||||
char index[3];
|
char index[4];
|
||||||
|
|
||||||
for (int n = 0; n <= maxIndex; ++n)
|
for (int n = 0; n <= maxIndex; ++n)
|
||||||
{
|
{
|
||||||
fileName dstName(src + "." + ext);
|
fileName dstName(src + "." + ext);
|
||||||
if (n)
|
if (n)
|
||||||
{
|
{
|
||||||
::sprintf(index, "%02d", n);
|
::snprintf(index, 4, "%02d", n);
|
||||||
dstName += index;
|
dstName += index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1639,6 +1639,7 @@ int Foam::system(const std::string& command, const bool bg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TBD: vfork is deprecated as of macOS 12.0
|
||||||
const pid_t child_pid = ::vfork(); // NB: vfork, not fork!
|
const pid_t child_pid = ::vfork(); // NB: vfork, not fork!
|
||||||
|
|
||||||
if (child_pid == -1)
|
if (child_pid == -1)
|
||||||
@ -1698,6 +1699,7 @@ int Foam::system(const CStringList& command, const bool bg)
|
|||||||
// The normal system() command has a fork buried in it that causes
|
// The normal system() command has a fork buried in it that causes
|
||||||
// issues with infiniband and openmpi etc.
|
// issues with infiniband and openmpi etc.
|
||||||
|
|
||||||
|
// TBD: vfork is deprecated as of macOS 12.0
|
||||||
const pid_t child_pid = ::vfork();
|
const pid_t child_pid = ::vfork();
|
||||||
|
|
||||||
if (child_pid == -1)
|
if (child_pid == -1)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -234,7 +234,7 @@ void Foam::fileFormats::STLCore::writeBinaryHeader
|
|||||||
{
|
{
|
||||||
// STL header with extra information about nTris
|
// STL header with extra information about nTris
|
||||||
char header[STLHeaderSize];
|
char header[STLHeaderSize];
|
||||||
sprintf(header, "STL binary file %u facets", nTris);
|
::snprintf(header, STLHeaderSize, "STL binary file %u facets", nTris);
|
||||||
|
|
||||||
// Fill trailing with zeroes (to avoid writing junk)
|
// Fill trailing with zeroes (to avoid writing junk)
|
||||||
for (size_t i = strlen(header); i < STLHeaderSize; ++i)
|
for (size_t i = strlen(header); i < STLHeaderSize; ++i)
|
||||||
|
|||||||
Reference in New Issue
Block a user