Kaydet (Commit) 44f720b1 authored tarafından Julien Chaffraix's avatar Julien Chaffraix Kaydeden (comit) Michael Meeks

Refactored the safeWrite method in a new file.

This enables other files to use it, which will be added in a follow-up step.
üst 50a89f08
......@@ -78,7 +78,8 @@ SLOFILES= \
$(SLO)$/file_volume.obj \
$(SLO)$/uunxapi.obj\
$(SLO)$/process_impl.obj\
$(SLO)$/salinit.obj
$(SLO)$/salinit.obj \
$(SLO)$/readwrite_helper.obj
OBJFILES= $(OBJ)$/conditn.obj \
$(OBJ)$/diagnose.obj \
......@@ -107,7 +108,8 @@ OBJFILES= $(OBJ)$/conditn.obj \
$(OBJ)$/file_volume.obj \
$(OBJ)$/uunxapi.obj\
$(OBJ)$/process_impl.obj\
$(OBJ)$/salinit.obj
$(OBJ)$/salinit.obj \
$(OBJ)$/readwrite_helper.obj
.IF "$(OS)"=="MACOSX"
......
......@@ -64,6 +64,7 @@
#include <grp.h>
#include "procimpl.h"
#include "readwrite_helper.h"
#include "sockimpl.h"
#include "secimpl.h"
......@@ -300,23 +301,6 @@ static sal_Bool sendFdPipe(int PipeFD, int SocketFD)
return bRet;
}
static sal_Bool safeWrite(int socket, void* data, sal_uInt32 dataSize)
{
sal_Int32 nToWrite = dataSize;
// Check for overflow as we convert a signed to an unsigned.
OSL_ASSERT(dataSize == (sal_uInt32)nToWrite);
while ( nToWrite ) {
sal_Int32 nWritten = write(socket, data, nToWrite);
if ( nWritten < 0 )
return sal_False;
OSL_ASSERT(nWritten > 0);
nToWrite -= nWritten;
}
return sal_True;
}
/**********************************************
receiveFdPipe
*********************************************/
......
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
* Julien Chaffraix <julien.chaffraix@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2011 the
* Initial Developer. All Rights Reserved.
*
* Major Contributor(s):
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#include "readwrite_helper.h"
#include <osl/diagnose.h>
#include <system.h>
sal_Bool safeWrite(int fd, void* data, sal_uInt32 dataSize)
{
sal_Int32 nToWrite = dataSize;
// Check for overflow as we convert a signed to an unsigned.
OSL_ASSERT(dataSize == (sal_uInt32)nToWrite);
while ( nToWrite ) {
sal_Int32 nWritten = write(fd, data, nToWrite);
if ( nWritten < 0 )
return sal_False;
OSL_ASSERT(nWritten > 0);
nToWrite -= nWritten;
}
return sal_True;
}
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
* Julien Chaffraix <julien.chaffraix@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2011 the
* Initial Developer. All Rights Reserved.
*
* Major Contributor(s):
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#include <sal/types.h>
sal_Bool safeWrite( int fd, void* data, sal_uInt32 dataSize );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment