hrev53245 adds 4 changesets to branch 'master'
old head: 42e3c6f97874f37701385e7027c77e4366d7c450
new head: 9d06690edec597ce6828c02b1f657b5f111ba9b6
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=9d06690edec5+%5E42e3c6f97874
----------------------------------------------------------------------------
394fba668430: unistd.h: POSIX_THREAD_ATTR_STACKADDR was implemented back in
March.
1418cade558a: file_systems: Pass size argument to ioctl in a lot more places.
4c9e8f77e41a: BootManager: Take explicit instead of implicit reference.
Passing a type& to a va-args turns it into a pointer as per
the Itanium ABI; but we shouldn't rely on such trickery.
Explicitly capture a reference to it instead.
9d06690edec5: userland: Pass more sizes with ioctls where we can.
No "functional" change intended.
[ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]
----------------------------------------------------------------------------
19 files changed, 129 insertions(+), 125 deletions(-)
headers/posix/unistd.h | 2 +-
.../devices/keyboard/KeyboardInputDevice.cpp | 9 +-
.../devices/tablet/TabletInputDevice.cpp | 2 +-
src/add-ons/kernel/file_systems/bfs/Volume.cpp | 4 +-
src/add-ons/kernel/file_systems/btrfs/Volume.cpp | 4 +-
src/add-ons/kernel/file_systems/cdda/cdda.cpp | 2 +-
src/add-ons/kernel/file_systems/exfat/Volume.cpp | 8 +-
src/add-ons/kernel/file_systems/ext2/Volume.cpp | 40 ++---
src/add-ons/kernel/file_systems/fat/dosfs.c | 2 +-
.../kernel/file_systems/iso9660/iso9660.cpp | 5 +-
.../kernel/file_systems/udf/kernel_interface.cpp | 4 +-
src/apps/bootmanager/LegacyBootMenu.cpp | 2 +-
src/apps/diskprobe/DataEditor.cpp | 3 +-
src/apps/terminal/Shell.cpp | 2 +-
src/bin/consoled/consoled.cpp | 9 +-
src/bin/ramdisk.cpp | 2 +-
src/kits/device/SerialPort.cpp | 146 +++++++++----------
src/kits/storage/Mime.cpp | 4 +-
src/servers/net/Services.cpp | 4 +-
############################################################################
Commit: 394fba668430a82ef6aafb78f450d902542729d7
URL: https://git.haiku-os.org/haiku/commit/?id=394fba668430
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Fri Jul 12 03:05:27 2019 UTC
unistd.h: POSIX_THREAD_ATTR_STACKADDR was implemented back in March.
----------------------------------------------------------------------------
diff --git a/headers/posix/unistd.h b/headers/posix/unistd.h
index 63889cec25..fd2c0684cb 100644
--- a/headers/posix/unistd.h
+++ b/headers/posix/unistd.h
@@ -44,7 +44,7 @@
#define _POSIX_THREADS (200112L)
#define _POSIX_MAPPED_FILES (200809L)
#define _POSIX_THREAD_PROCESS_SHARED (200809L)
-#define _POSIX_THREAD_ATTR_STACKADDR (-1) /* currently
unsupported */
+#define _POSIX_THREAD_ATTR_STACKADDR (200809L)
#define _POSIX_THREAD_ATTR_STACKSIZE (200809L)
#define _POSIX_THREAD_PRIORITY_SCHEDULING (-1) /* currently
unsupported */
#define _POSIX_REALTIME_SIGNALS (200809L)
############################################################################
Commit: 1418cade558ac4fd72282c9c462e178b44e62ef7
URL: https://git.haiku-os.org/haiku/commit/?id=1418cade558a
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Fri Jul 12 03:26:02 2019 UTC
file_systems: Pass size argument to ioctl in a lot more places.
----------------------------------------------------------------------------
diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.cpp
b/src/add-ons/kernel/file_systems/bfs/Volume.cpp
index 5327b9b22d..ca3241fd24 100644
--- a/src/add-ons/kernel/file_systems/bfs/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/bfs/Volume.cpp
@@ -102,7 +102,7 @@ DeviceOpener::Open(const char* device, int mode)
if (_IsReadWrite(mode)) {
// check out if the device really allows for read/write
access
device_geometry geometry;
- if (!ioctl(fDevice, B_GET_GEOMETRY, &geometry)) {
+ if (!ioctl(fDevice, B_GET_GEOMETRY, &geometry,
sizeof(device_geometry))) {
if (geometry.read_only) {
// reopen device read-only
close(fDevice);
@@ -162,7 +162,7 @@ status_t
DeviceOpener::GetSize(off_t* _size, uint32* _blockSize)
{
device_geometry geometry;
- if (ioctl(fDevice, B_GET_GEOMETRY, &geometry) < 0) {
+ if (ioctl(fDevice, B_GET_GEOMETRY, &geometry, sizeof(device_geometry))
< 0) {
// maybe it's just a file
struct stat stat;
if (fstat(fDevice, &stat) < 0)
diff --git a/src/add-ons/kernel/file_systems/btrfs/Volume.cpp
b/src/add-ons/kernel/file_systems/btrfs/Volume.cpp
index 4aff9ec0a7..c1bfbaf331 100644
--- a/src/add-ons/kernel/file_systems/btrfs/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/btrfs/Volume.cpp
@@ -106,7 +106,7 @@ DeviceOpener::Open(const char* device, int mode)
if (_IsReadWrite(mode)) {
// check out if the device really allows for read/write
access
device_geometry geometry;
- if (!ioctl(fDevice, B_GET_GEOMETRY, &geometry)) {
+ if (!ioctl(fDevice, B_GET_GEOMETRY, &geometry,
sizeof(device_geometry))) {
if (geometry.read_only) {
// reopen device read-only
close(fDevice);
@@ -166,7 +166,7 @@ status_t
DeviceOpener::GetSize(off_t* _size, uint32* _blockSize)
{
device_geometry geometry;
- if (ioctl(fDevice, B_GET_GEOMETRY, &geometry) < 0) {
+ if (ioctl(fDevice, B_GET_GEOMETRY, &geometry, sizeof(device_geometry))
< 0) {
// maybe it's just a file
struct stat stat;
if (fstat(fDevice, &stat) < 0)
diff --git a/src/add-ons/kernel/file_systems/cdda/cdda.cpp
b/src/add-ons/kernel/file_systems/cdda/cdda.cpp
index 31bddb5ac7..0755d25c48 100644
--- a/src/add-ons/kernel/file_systems/cdda/cdda.cpp
+++ b/src/add-ons/kernel/file_systems/cdda/cdda.cpp
@@ -506,7 +506,7 @@ read_frames(int fd, off_t firstFrame, uint8 *buffer, size_t
count)
read.buffer = (char *)buffer;
read.play = false;
- if (ioctl(fd, B_SCSI_READ_CD, &read) < 0) {
+ if (ioctl(fd, B_SCSI_READ_CD, &read, sizeof(scsi_read_cd)) < 0)
{
// drive couldn't read data - try again to read with a
smaller block size
if (count == 1)
return errno;
diff --git a/src/add-ons/kernel/file_systems/exfat/Volume.cpp
b/src/add-ons/kernel/file_systems/exfat/Volume.cpp
index b6f7b1a7f3..65dcb39c6b 100644
--- a/src/add-ons/kernel/file_systems/exfat/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/exfat/Volume.cpp
@@ -122,7 +122,7 @@ DeviceOpener::Open(const char* device, int mode)
if (_IsReadWrite(mode)) {
// check out if the device really allows for read/write
access
device_geometry geometry;
- if (!ioctl(fDevice, B_GET_GEOMETRY, &geometry)) {
+ if (!ioctl(fDevice, B_GET_GEOMETRY, &geometry,
sizeof(device_geometry))) {
if (geometry.read_only) {
// reopen device read-only
close(fDevice);
@@ -182,7 +182,7 @@ status_t
DeviceOpener::GetSize(off_t* _size, uint32* _blockSize)
{
device_geometry geometry;
- if (ioctl(fDevice, B_GET_GEOMETRY, &geometry) < 0) {
+ if (ioctl(fDevice, B_GET_GEOMETRY, &geometry, sizeof(device_geometry))
< 0) {
// maybe it's just a file
struct stat stat;
if (fstat(fDevice, &stat) < 0)
@@ -255,7 +255,7 @@ exfat_super_block::IsValid()
return false;
if (version_minor != 0 || version_major != 1)
return false;
-
+
return true;
}
@@ -480,7 +480,7 @@ Volume::GetIno(cluster_t cluster, uint32 offset, ino_t
parent)
node->parent = parent;
fNodeTree.Insert(node);
fInoTree.Insert(node);
- TRACE("Volume::GetIno() new cluster %" B_PRIu32 " offset %" B_PRIu32
+ TRACE("Volume::GetIno() new cluster %" B_PRIu32 " offset %" B_PRIu32
" ino %" B_PRIdINO "\n", cluster, offset, node->ino);
return node->ino;
}
diff --git a/src/add-ons/kernel/file_systems/ext2/Volume.cpp
b/src/add-ons/kernel/file_systems/ext2/Volume.cpp
index 42eb9e3858..e14a24fecf 100644
--- a/src/add-ons/kernel/file_systems/ext2/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/ext2/Volume.cpp
@@ -111,7 +111,7 @@ DeviceOpener::Open(const char* device, int mode)
if (_IsReadWrite(mode)) {
// check out if the device really allows for read/write
access
device_geometry geometry;
- if (!ioctl(fDevice, B_GET_GEOMETRY, &geometry)) {
+ if (!ioctl(fDevice, B_GET_GEOMETRY, &geometry,
sizeof(device_geometry))) {
if (geometry.read_only) {
// reopen device read-only
close(fDevice);
@@ -171,7 +171,7 @@ status_t
DeviceOpener::GetSize(off_t* _size, uint32* _blockSize)
{
device_geometry geometry;
- if (ioctl(fDevice, B_GET_GEOMETRY, &geometry) < 0) {
+ if (ioctl(fDevice, B_GET_GEOMETRY, &geometry, sizeof(device_geometry))
< 0) {
// maybe it's just a file
struct stat stat;
if (fstat(fDevice, &stat) < 0)
@@ -210,7 +210,7 @@ ext2_super_block::IsValid()
|| ReservedGDTBlocks() > (1UL << BlockShift()) / 4) {
return false;
}
-
+
return true;
}
@@ -283,7 +283,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
{
// flags |= B_MOUNT_READ_ONLY;
// we only support read-only for now
-
+
if ((flags & B_MOUNT_READ_ONLY) != 0) {
TRACE("Volume::Mount(): Read only\n");
} else {
@@ -312,7 +312,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
FATAL("Volume::Mount(): Identify() failed\n");
return status;
}
-
+
// check read-only features if mounting read-write
if (!IsReadOnly() && _UnsupportedReadOnlyFeatures(fSuperBlock) != 0)
return B_UNSUPPORTED;
@@ -345,7 +345,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
TRACE("block size %" B_PRIu32 ", num groups %" B_PRIu32 ", groups per "
"block %" B_PRIu32 ", first %" B_PRIu32 "\n", fBlockSize,
fNumGroups,
fGroupsPerBlock, fFirstDataBlock);
-
+
uint32 blockCount = (fNumGroups + fGroupsPerBlock - 1) /
fGroupsPerBlock;
fGroupBlocks = (uint8**)malloc(blockCount * sizeof(uint8*));
@@ -366,7 +366,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
fBlockCache = opener.InitCache(NumBlocks(), fBlockSize);
if (fBlockCache == NULL)
return B_ERROR;
-
+
TRACE("Volume::Mount(): Initialized block cache: %p\n", fBlockCache);
// initialize journal if mounted read-write
@@ -374,7 +374,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
(fSuperBlock.CompatibleFeatures() & EXT2_FEATURE_HAS_JOURNAL)
!= 0) {
// TODO: There should be a mount option to ignore the existent
journal
if (fSuperBlock.JournalInode() != 0) {
- fJournalInode = new(std::nothrow) Inode(this,
+ fJournalInode = new(std::nothrow) Inode(this,
fSuperBlock.JournalInode());
if (fJournalInode == NULL)
@@ -526,7 +526,7 @@ Volume::_UnsupportedIncompatibleFeatures(ext2_super_block&
superBlock)
| EXT2_INCOMPATIBLE_FEATURE_EXTENTS
| EXT2_INCOMPATIBLE_FEATURE_FLEX_GROUP;
/*| EXT2_INCOMPATIBLE_FEATURE_META_GROUP*/;
- uint32 unsupported = superBlock.IncompatibleFeatures()
+ uint32 unsupported = superBlock.IncompatibleFeatures()
& ~supportedIncompatible;
if (unsupported != 0) {
@@ -585,7 +585,7 @@ Volume::_GroupCheckSum(ext2_block_group *group, int32 index)
checksum = calculate_crc(checksum, (uint8*)&number,
sizeof(number));
checksum = calculate_crc(checksum, (uint8*)group, 30);
if (Has64bitFeature()) {
- checksum = calculate_crc(checksum, (uint8*)group + 34,
+ checksum = calculate_crc(checksum, (uint8*)group + 34,
fGroupDescriptorSize - 34);
}
}
@@ -621,13 +621,13 @@ Volume::GetBlockGroup(int32 index, ext2_block_group**
_group)
memcpy(fGroupBlocks[blockIndex], block, fBlockSize);
TRACE("group [%" B_PRId32 "]: inode table %" B_PRIu64 "\n",
index,
- ((ext2_block_group*)(fGroupBlocks[blockIndex] +
blockOffset
+ ((ext2_block_group*)(fGroupBlocks[blockIndex] +
blockOffset
*
fGroupDescriptorSize))->InodeTable(Has64bitFeature()));
}
*_group = (ext2_block_group*)(fGroupBlocks[blockIndex]
+ blockOffset * fGroupDescriptorSize);
- if (HasChecksumFeature()
+ if (HasChecksumFeature()
&& (*_group)->checksum != _GroupCheckSum(*_group, index)) {
return B_BAD_DATA;
}
@@ -653,7 +653,7 @@ Volume::WriteBlockGroup(Transaction& transaction, int32
index)
ext2_block_group *group = (ext2_block_group*)(fGroupBlocks[blockIndex]
+ blockOffset * fGroupDescriptorSize);
-
+
group->checksum = _GroupCheckSum(group, index);
TRACE("Volume::WriteBlockGroup() checksum 0x%x for group %" B_PRId32 " "
"(free inodes %" B_PRIu32 ", unused %" B_PRIu32 ")\n",
group->checksum,
@@ -677,13 +677,13 @@ Volume::WriteBlockGroup(Transaction& transaction, int32
index)
status_t
Volume::ActivateLargeFiles(Transaction& transaction)
{
- if ((fSuperBlock.ReadOnlyFeatures()
+ if ((fSuperBlock.ReadOnlyFeatures()
& EXT2_READ_ONLY_FEATURE_LARGE_FILE) != 0)
return B_OK;
-
+
fSuperBlock.SetReadOnlyFeatures(fSuperBlock.ReadOnlyFeatures()
| EXT2_READ_ONLY_FEATURE_LARGE_FILE);
-
+
return WriteSuperBlock(transaction);
}
@@ -691,13 +691,13 @@ Volume::ActivateLargeFiles(Transaction& transaction)
status_t
Volume::ActivateDirNLink(Transaction& transaction)
{
- if ((fSuperBlock.ReadOnlyFeatures()
+ if ((fSuperBlock.ReadOnlyFeatures()
& EXT2_READ_ONLY_FEATURE_DIR_NLINK) != 0)
return B_OK;
-
+
fSuperBlock.SetReadOnlyFeatures(fSuperBlock.ReadOnlyFeatures()
| EXT2_READ_ONLY_FEATURE_DIR_NLINK);
-
+
return WriteSuperBlock(transaction);
}
@@ -734,7 +734,7 @@ Volume::RemoveOrphan(Transaction& transaction, ino_t id)
ext2_inode* inode = (ext2_inode*)(block
+ InodeBlockIndex(currentID) * InodeSize());
-
+
if (currentID == id) {
TRACE("Volume::RemoveOrphan(): First entry. Updating head to:
%d\n",
(int)inode->NextOrphan());
diff --git a/src/add-ons/kernel/file_systems/fat/dosfs.c
b/src/add-ons/kernel/file_systems/fat/dosfs.c
index bfa61481ab..f4062e4504 100644
--- a/src/add-ons/kernel/file_systems/fat/dosfs.c
+++ b/src/add-ons/kernel/file_systems/fat/dosfs.c
@@ -525,7 +525,7 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int
flags,
}
// get device characteristics
- if (ioctl(fd, B_GET_GEOMETRY, &geo) < 0) {
+ if (ioctl(fd, B_GET_GEOMETRY, &geo, sizeof(device_geometry)) < 0) {
struct stat st;
if (fstat(fd, &st) >= 0 && S_ISREG(st.st_mode)) {
/* support mounting disk images */
diff --git a/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp
b/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp
index f02a22c5c5..f88fa71b88 100644
--- a/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp
+++ b/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp
@@ -49,7 +49,7 @@ get_device_block_size(int fd)
{
device_geometry geometry;
- if (ioctl(fd, B_GET_GEOMETRY, &geometry) < 0) {
+ if (ioctl(fd, B_GET_GEOMETRY, &geometry, sizeof(device_geometry)) < 0)
{
struct stat st;
if (fstat(fd, &st) < 0 || S_ISDIR(st.st_mode))
return 0;
@@ -628,7 +628,8 @@ ISOMount(const char *path, uint32 flags, iso9660_volume
**_newVolume,
/* try to open the raw device to get access to the other sessions as
well */
if (volume->fdOfSession >= 0) {
- if (ioctl(volume->fdOfSession, B_GET_PARTITION_INFO,
&partitionInfo) < 0) {
+ if (ioctl(volume->fdOfSession, B_GET_PARTITION_INFO,
&partitionInfo,
+ sizeof(partition_info)) < 0) {
TRACE(("B_GET_PARTITION_INFO: ioctl returned error\n"));
strcpy(partitionInfo.device, path);
}
diff --git a/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp
b/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp
index 7c0b6d40de..2ec9852a94 100644
--- a/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp
+++ b/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp
@@ -560,7 +560,7 @@ udf_mount(fs_volume *_volume, const char *_device, uint32
flags,
//
// If that fails, you're just SOL.
- if (ioctl(device, B_GET_PARTITION_INFO, &info) == 0) {
+ if (ioctl(device, B_GET_PARTITION_INFO, &info,
sizeof(partition_info)) == 0) {
TRACE(("partition_info:\n"));
TRACE(("\toffset: %Ld\n", info.offset));
TRACE(("\tsize: %Ld\n", info.size));
@@ -571,7 +571,7 @@ udf_mount(fs_volume *_volume, const char *_device, uint32
flags,
_device = info.device;
deviceOffset = info.offset / info.logical_block_size;
numBlock = deviceOffset + info.size /
info.logical_block_size;
- } else if (ioctl(device, B_GET_GEOMETRY, &geometry) == 0) {
+ } else if (ioctl(device, B_GET_GEOMETRY, &geometry,
sizeof(device_geometry)) == 0) {
TRACE(("geometry_info:\n"));
TRACE(("\tsectors_per_track: %ld\n",
geometry.sectors_per_track));
TRACE(("\tcylinder_count: %ld\n",
geometry.cylinder_count));
############################################################################
Commit: 4c9e8f77e41aa097396649d45b86cf7a8358cf9b
URL: https://git.haiku-os.org/haiku/commit/?id=4c9e8f77e41a
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Fri Jul 12 03:40:41 2019 UTC
BootManager: Take explicit instead of implicit reference.
Passing a type& to a va-args turns it into a pointer as per
the Itanium ABI; but we shouldn't rely on such trickery.
Explicitly capture a reference to it instead.
----------------------------------------------------------------------------
diff --git a/src/apps/bootmanager/LegacyBootMenu.cpp
b/src/apps/bootmanager/LegacyBootMenu.cpp
index 297e29789c..a8935e287c 100644
--- a/src/apps/bootmanager/LegacyBootMenu.cpp
+++ b/src/apps/bootmanager/LegacyBootMenu.cpp
@@ -612,7 +612,7 @@ LegacyBootMenu::_GetBIOSDrive(const char* device, int8&
drive)
if (fd < 0)
return errno;
- status_t status = ioctl(fd, B_GET_BIOS_DRIVE_ID, drive, 1);
+ status_t status = ioctl(fd, B_GET_BIOS_DRIVE_ID, &drive, 1);
close(fd);
return status;
}
############################################################################
Revision: hrev53245
Commit: 9d06690edec597ce6828c02b1f657b5f111ba9b6
URL: https://git.haiku-os.org/haiku/commit/?id=9d06690edec5
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Fri Jul 12 03:41:52 2019 UTC
userland: Pass more sizes with ioctls where we can.
No "functional" change intended.
----------------------------------------------------------------------------
diff --git a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp
b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp
index 8571770da7..9ceecd3a9d 100644
--- a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp
+++ b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp
@@ -284,7 +284,8 @@ KeyboardDevice::_ControlThread()
memset(states, 0, sizeof(states));
if (fKeyboardID == 0) {
- if (ioctl(fFD, KB_GET_KEYBOARD_ID, &fKeyboardID) == 0) {
+ if (ioctl(fFD, KB_GET_KEYBOARD_ID, &fKeyboardID,
+ sizeof(fKeyboardID)) == 0) {
BMessage message(IS_SET_KEYBOARD_ID);
message.AddInt16("id", fKeyboardID);
be_app->PostMessage(&message);
@@ -529,7 +530,7 @@ KeyboardDevice::_UpdateSettings(uint32 opcode)
if (get_key_repeat_rate(&fSettings.key_repeat_rate) != B_OK) {
LOG_ERR("error when get_key_repeat_rate\n");
} else if (ioctl(fFD, KB_SET_KEY_REPEAT_RATE,
- &fSettings.key_repeat_rate) != B_OK) {
+ &fSettings.key_repeat_rate, sizeof(int32)) !=
B_OK) {
LOG_ERR("error when KB_SET_KEY_REPEAT_RATE, fd:%d\n",
fFD);
}
}
@@ -538,7 +539,7 @@ KeyboardDevice::_UpdateSettings(uint32 opcode)
if (get_key_repeat_delay(&fSettings.key_repeat_delay) != B_OK) {
LOG_ERR("error when get_key_repeat_delay\n");
} else if (ioctl(fFD, KB_SET_KEY_REPEAT_DELAY,
- &fSettings.key_repeat_delay) != B_OK) {
+ &fSettings.key_repeat_delay, sizeof(bigtime_t))
!= B_OK) {
LOG_ERR("error when KB_SET_KEY_REPEAT_DELAY, fd:%d\n",
fFD);
}
}
@@ -570,7 +571,7 @@ KeyboardDevice::_UpdateLEDs()
if ((fModifiers & B_SCROLL_LOCK) != 0)
lockIO[2] = 1;
- ioctl(fFD, KB_SET_LEDS, &lockIO);
+ ioctl(fFD, KB_SET_LEDS, &lockIO, sizeof(lockIO));
}
diff --git a/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp
b/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp
index 1153997d68..f5965d4149 100644
--- a/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp
+++ b/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp
@@ -413,7 +413,7 @@ TabletDevice::_UpdateSettings()
if (get_click_speed(&fSettings.click_speed) != B_OK)
LOG_ERR("error when get_click_speed\n");
else
- ioctl(fDevice, MS_SET_CLICKSPEED, &fSettings.click_speed);
+ ioctl(fDevice, MS_SET_CLICKSPEED, &fSettings.click_speed,
sizeof(bigtime_t));
}
diff --git a/src/apps/diskprobe/DataEditor.cpp
b/src/apps/diskprobe/DataEditor.cpp
index d537785ff4..0b22a01171 100644
--- a/src/apps/diskprobe/DataEditor.cpp
+++ b/src/apps/diskprobe/DataEditor.cpp
@@ -499,7 +499,8 @@ DataEditor::SetTo(BEntry &entry, const char *attribute)
} else if (fIsDevice) {
device_geometry geometry;
int device = fFile.Dup();
- if (device < 0 || ioctl(device, B_GET_GEOMETRY, &geometry) < 0)
{
+ if (device < 0 || ioctl(device, B_GET_GEOMETRY, &geometry,
+ sizeof(geometry)) < 0) {
if (device >= 0)
close(device);
fFile.Unset();
diff --git a/src/apps/terminal/Shell.cpp b/src/apps/terminal/Shell.cpp
index bb26169ae5..a35b652d73 100644
--- a/src/apps/terminal/Shell.cpp
+++ b/src/apps/terminal/Shell.cpp
@@ -536,7 +536,7 @@ Shell::_Spawn(int row, int col, const ShellParameters&
parameters)
struct winsize ws = { handshake.row, handshake.col };
- ioctl(0, TIOCSWINSZ, &ws);
+ ioctl(0, TIOCSWINSZ, &ws, sizeof(ws));
tcsetpgrp(0, getpgrp());
// set this process group ID as the controlling terminal
diff --git a/src/bin/consoled/consoled.cpp b/src/bin/consoled/consoled.cpp
index 1b38c04151..4469dc6d2f 100644
--- a/src/bin/consoled/consoled.cpp
+++ b/src/bin/consoled/consoled.cpp
@@ -56,7 +56,7 @@ error(const char* message, ...)
va_list args;
va_start(args, message);
-
+
vsnprintf(buffer, sizeof(buffer), message, args);
va_end(args);
@@ -79,7 +79,7 @@ update_leds(int fd, uint32 modifiers)
if ((modifiers & B_SCROLL_LOCK) != 0)
lockIO[2] = 1;
- ioctl(fd, KB_SET_LEDS, &lockIO);
+ ioctl(fd, KB_SET_LEDS, &lockIO, sizeof(lockIO));
}
@@ -106,7 +106,8 @@ keyboard_reader(void* arg)
for (;;) {
raw_key_info rawKeyInfo;
- if (ioctl(keyboard->device, KB_READ, &rawKeyInfo) != 0)
+ if (ioctl(keyboard->device, KB_READ, &rawKeyInfo,
+ sizeof(rawKeyInfo)) != 0)
break;
uint32 keycode = rawKeyInfo.keycode;
@@ -313,7 +314,7 @@ start_console(struct console* con)
continue;
snprintf(name, sizeof(name), "/dev/pt/%s",
entry->d_name);
-
+
con->tty_master_fd = open(name, O_RDWR);
if (con->tty_master_fd >= 0) {
snprintf(name, sizeof(name), "/dev/tt/%s",
entry->d_name);
diff --git a/src/bin/ramdisk.cpp b/src/bin/ramdisk.cpp
index e82f0fc01f..4681733d54 100644
--- a/src/bin/ramdisk.cpp
+++ b/src/bin/ramdisk.cpp
@@ -412,7 +412,7 @@ command_list(int argc, const char* const* argv)
// issue the request
ram_disk_ioctl_info request;
- if (ioctl(fd, RAM_DISK_IOCTL_INFO, &request) < 0)
+ if (ioctl(fd, RAM_DISK_IOCTL_INFO, &request, sizeof(request)) <
0)
continue;
int32 rowIndex = table.CountRows();
diff --git a/src/kits/device/SerialPort.cpp b/src/kits/device/SerialPort.cpp
index a4255569de..37f4c36063 100644
--- a/src/kits/device/SerialPort.cpp
+++ b/src/kits/device/SerialPort.cpp
@@ -20,8 +20,8 @@
#include <termios.h>
-/* The directory where the serial driver publishes its devices */
-#define SERIAL_DIR "/dev/ports"
+/* The directory where the serial driver publishes its devices */
+#define SERIAL_DIR "/dev/ports"
// Scans a directory and adds the entries it founds as strings to the
// given list
@@ -31,19 +31,19 @@ scan_directory(const char *directory, BList *list)
BEntry entry;
BDirectory dir(SERIAL_DIR);
char buf[B_OS_NAME_LENGTH];
-
+
ASSERT(list != NULL);
while (dir.GetNextEntry(&entry) == B_OK) {
entry.GetName(buf);
list->AddItem(strdup(buf));
};
-
+
return list->CountItems();
}
/*! \brief Creates and initializes a BSerialPort object.
-
+
Query the driver, and builds a list of the available
serial ports.
The BSerialPort object is initialized to these values:
@@ -73,17 +73,17 @@ BSerialPort::BSerialPort()
/*! \brief Frees the resources associated with the object.
Closes the port, if it's open, and deletes the devices list.
-*/
+*/
BSerialPort::~BSerialPort()
{
if (ffd >= 0)
close(ffd);
-
+
if (fDevices != NULL) {
for (int32 count = fDevices->CountItems() - 1; count >= 0;
count--)
free(fDevices->RemoveItem(count));
delete fDevices;
- }
+ }
}
@@ -98,36 +98,36 @@ status_t
BSerialPort::Open(const char *portName)
{
char buf[64];
-
+
if (portName == NULL)
return B_BAD_VALUE; // Heheee, we won't crash
-
- if (portName[0] != '/')
+
+ if (portName[0] != '/')
snprintf(buf, 64, SERIAL_DIR"/%s", portName);
else
// A name like "/dev/ports/serial2" was passed
snprintf(buf, 64, "%s", portName);
-
+
if (ffd >= 0) //If this port is already open, close it
close(ffd);
-
+
// TODO: BeOS don't use O_EXCL, and this seems to lead
// to some issues. I added this flag having read some comments
// by Marco Nelissen on the annotated BeBook.
// I think BeOS uses O_RDWR|O_NONBLOCK here.
- ffd = open(buf, O_RDWR | O_NONBLOCK | O_EXCL);
-
+ ffd = open(buf, O_RDWR | O_NONBLOCK | O_EXCL);
+
if (ffd >= 0) {
// we used open() with O_NONBLOCK flag to let it return
immediately,
// but we want read/write operations to block if needed,
// so we clear that bit here.
int flags = fcntl(ffd, F_GETFL);
fcntl(ffd, F_SETFL, flags & ~O_NONBLOCK);
-
+
_DriverControl();
}
- // TODO: I wonder why the return type is a status_t,
- // since we (as BeOS does) return the descriptor number for the
device...
+ // TODO: I wonder why the return type is a status_t,
+ // since we (as BeOS does) return the descriptor number for the
device...
return (ffd >= 0) ? ffd : errno;
}
@@ -152,7 +152,7 @@ ssize_t
BSerialPort::Read(void *buf, size_t count)
{
ssize_t err = read(ffd, buf, count);
-
+
return (err >= 0) ? err : errno;
}
@@ -165,7 +165,7 @@ ssize_t
BSerialPort::Write(const void *buf, size_t count)
{
ssize_t err = write(ffd, buf, count);
-
+
return (err >= 0) ? err : errno;
}
@@ -190,9 +190,9 @@ BSerialPort::SetBlocking(bool Blocking)
*/
status_t
BSerialPort::SetTimeout(bigtime_t microSeconds)
-{
+{
status_t err = B_BAD_VALUE;
-
+
if (microSeconds == B_INFINITE_TIMEOUT || microSeconds <= 25000000) {
fTimeout = microSeconds;
_DriverControl();
@@ -225,7 +225,7 @@ BSerialPort::SetTimeout(bigtime_t microSeconds)
- \c B_115200_BPS
- \c B_230400_BPS
- \c B_31250_BPS
- \return
+ \return
- \c B_OK if all goes fine,
- an error code if something goes wrong.
*/
@@ -233,7 +233,7 @@ status_t
BSerialPort::SetDataRate(data_rate bitsPerSecond)
{
fBaudRate = bitsPerSecond;
-
+
return _DriverControl();
}
@@ -352,7 +352,7 @@ BSerialPort::SetFlowControl(uint32 method)
/*! \brief Returns the selected flow control.
- \return The flow control for the current open port.
+ \return The flow control for the current open port.
*/
uint32
BSerialPort::FlowControl(void)
@@ -365,8 +365,8 @@ BSerialPort::FlowControl(void)
status_t
BSerialPort::SetDTR(bool asserted)
{
- status_t status = ioctl(ffd, TCSETDTR, &asserted);
-
+ status_t status = ioctl(ffd, TCSETDTR, &asserted, sizeof(asserted));
+
return (status >= 0) ? status : errno;
}
@@ -375,8 +375,8 @@ BSerialPort::SetDTR(bool asserted)
status_t
BSerialPort::SetRTS(bool asserted)
{
- status_t status = ioctl(ffd, TCSETRTS, &asserted);
-
+ status_t status = ioctl(ffd, TCSETRTS, &asserted, sizeof(asserted));
+
return (status >= 0) ? status : errno;
}
@@ -392,8 +392,8 @@ BSerialPort::NumCharsAvailable(int32 *numChars)
//No help from the BeBook...
if (ffd < 0)
return B_NO_INIT;
-
- // TODO: Implement ?
+
+ // TODO: Implement ?
if (numChars)
*numChars = 0;
return B_OK;
@@ -406,11 +406,11 @@ BSerialPort::NumCharsAvailable(int32 *numChars)
bool
BSerialPort::IsCTS(void)
{
- unsigned int bits = ioctl(ffd, TCGETBITS, 0);
-
+ unsigned int bits = ioctl(ffd, TCGETBITS, 0);
+
if (bits & TCGB_CTS)
return true;
-
+
return false;
}
@@ -421,11 +421,11 @@ BSerialPort::IsCTS(void)
bool
BSerialPort::IsDSR(void)
{
- unsigned int bits = ioctl(ffd, TCGETBITS, 0);
-
+ unsigned int bits = ioctl(ffd, TCGETBITS, 0);
+
if (bits & TCGB_DSR)
return true;
-
+
return false;
}
@@ -436,11 +436,11 @@ BSerialPort::IsDSR(void)
bool
BSerialPort::IsRI(void)
{
- unsigned int bits = ioctl(ffd, TCGETBITS, 0);
-
+ unsigned int bits = ioctl(ffd, TCGETBITS, 0);
+
if (bits & TCGB_RI)
return true;
-
+
return false;
}
@@ -451,11 +451,11 @@ BSerialPort::IsRI(void)
bool
BSerialPort::IsDCD(void)
{
- unsigned int bits = ioctl(ffd, TCGETBITS, 0);
-
+ unsigned int bits = ioctl(ffd, TCGETBITS, 0);
+
if (bits & TCGB_DCD)
return true;
-
+
return false;
}
@@ -471,7 +471,7 @@ BSerialPort::WaitForInput(void)
{
ssize_t size;
int err = ioctl(ffd, TCWAITEVENT, &size, sizeof size);
-
+
return (err < B_OK) ? errno : size;
}
@@ -484,14 +484,14 @@ int32
BSerialPort::CountDevices()
{
int32 count = 0;
-
+
// Refresh devices list
_ScanDevices();
-
+
if (fDevices != NULL)
count = fDevices->CountItems();
-
- return count;
+
+ return count;
}
@@ -508,7 +508,7 @@ BSerialPort::GetDeviceName(int32 n, char *name, size_t
bufSize)
{
status_t result = B_ERROR;
const char *dev = NULL;
-
+
if (fDevices != NULL)
dev = static_cast<char*>(fDevices->ItemAt(n));
@@ -525,7 +525,7 @@ BSerialPort::GetDeviceName(int32 n, char *name, size_t
bufSize)
/*! \brief Build a list of available serial ports.
Query the serial driver about the available devices,
- and build a list of them.
+ and build a list of them.
*/
void
BSerialPort::_ScanDevices()
@@ -534,9 +534,9 @@ BSerialPort::_ScanDevices()
if (fDevices != NULL) {
for (int32 count = fDevices->CountItems() - 1; count >= 0;
count--)
free(fDevices->RemoveItem(count));
-
+
// Add devices to the list
- scan_directory(SERIAL_DIR, fDevices);
+ scan_directory(SERIAL_DIR, fDevices);
}
}
@@ -551,67 +551,67 @@ BSerialPort::_DriverControl()
{
struct termios options;
int err;
-
+
if (ffd < 0)
return B_NO_INIT;
-
- //Load the current settings
+
+ //Load the current settings
err = tcgetattr(ffd, &options);
if (err < 0)
return errno;
-
- // Reset all flags
+
+ // Reset all flags
options.c_iflag &= ~(IXON | IXOFF | IXANY | INPCK);
options.c_cflag &= ~(CRTSCTS | CSIZE | CSTOPB | PARODD | PARENB);
options.c_lflag &= ~(ECHO | ECHONL | ISIG | ICANON);
-
+
// Local line
options.c_cflag |= CLOCAL;
-
+
//Set the flags to the wanted values
if (fFlow & B_HARDWARE_CONTROL)
options.c_cflag |= CRTSCTS;
-
+
if (fFlow & B_SOFTWARE_CONTROL)
options.c_iflag |= (IXON | IXOFF);
-
+
if (fStopBits & B_STOP_BITS_2)
options.c_cflag |= CSTOPB; // Set 2 stop bits
-
+
if (fDataBits & B_DATA_BITS_8)
options.c_cflag |= CS8; // Set 8 data bits
-
+
//Ok, set the parity now
if (fParityMode != B_NO_PARITY) {
options.c_cflag |= PARENB; //Enable parity
if (fParityMode == B_ODD_PARITY)
options.c_cflag |= PARODD; //Select odd parity
}
-
- //Set the baud rate
+
+ //Set the baud rate
cfsetispeed(&options, fBaudRate);
cfsetospeed(&options, fBaudRate);
-
+
//Set the timeout
- options.c_cc[VTIME] = 0;
+ options.c_cc[VTIME] = 0;
options.c_cc[VMIN] = 0;
if (fBlocking) {
if (fTimeout == B_INFINITE_TIMEOUT) {
options.c_cc[VMIN] = 1;
} else if (fTimeout != 0) {
- int timeout = fTimeout / 100000;
+ int timeout = fTimeout / 100000;
options.c_cc[VTIME] = (timeout == 0) ? 1 : timeout;
}
}
-
- //Ok, finished. Now tell the driver what we decided
+
+ //Ok, finished. Now tell the driver what we decided
err = tcsetattr(ffd, TCSANOW, &options);
-
- return (err >= 0) ? err : errno;
+
+ return (err >= 0) ? err : errno;
}
-/* These functions are here to maintain Binary Compatibility */
+/* These functions are here to maintain Binary Compatibility */
void BSerialPort::_ReservedSerialPort1() {}
void BSerialPort::_ReservedSerialPort2() {}
void BSerialPort::_ReservedSerialPort3() {}
diff --git a/src/kits/storage/Mime.cpp b/src/kits/storage/Mime.cpp
index badfef4f13..2208f4fc1e 100644
--- a/src/kits/storage/Mime.cpp
+++ b/src/kits/storage/Mime.cpp
@@ -118,7 +118,7 @@ get_device_icon(const char* device, void* icon, int32 size)
// attributes. Should those attributes override the icon returned by
// ioctl(,B_GET_ICON,)?
device_icon iconData = {size, icon};
- if (ioctl(fd, B_GET_ICON, &iconData) != 0) {
+ if (ioctl(fd, B_GET_ICON, &iconData, sizeof(device_icon)) != 0) {
// legacy icon was not available, try vector icon
close(fd);
@@ -230,7 +230,7 @@ get_device_icon(const char* device, uint8** _data, size_t*
_size,
// Try to get the icon by name first
char name[B_FILE_NAME_LENGTH];
- if (ioctl(fd, B_GET_ICON_NAME, name) >= 0) {
+ if (ioctl(fd, B_GET_ICON_NAME, name, sizeof(name)) >= 0) {
status_t status = get_named_icon(name, _data, _size, _type);
if (status == B_OK) {
close(fd);
diff --git a/src/servers/net/Services.cpp b/src/servers/net/Services.cpp
index 453f26f388..932b04c28c 100644
--- a/src/servers/net/Services.cpp
+++ b/src/servers/net/Services.cpp
@@ -508,13 +508,13 @@ Services::_Listener()
if (connection.Type() == SOCK_STREAM) {
// accept incoming connection
int value = 1;
- ioctl(i, FIONBIO, &value);
+ ioctl(i, FIONBIO, &value, sizeof(value));
// make sure we don't wait for the
connection
socket = accept(connection.socket, NULL, NULL);
value = 0;
- ioctl(i, FIONBIO, &value);
+ ioctl(i, FIONBIO, &value, sizeof(value));
if (socket < 0)
continue;