Skip to content

Commit

Permalink
Merge fixes to issues found while updating toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
le-jzr committed Oct 22, 2023
2 parents b2cbc0b + c63c2bb commit f4a4266
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 29 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ project(
'HelenOS',
[ 'c', 'cpp' ],
default_options : ['buildtype=plain', 'c_std=gnu11', 'cpp_std=c++17', 'warning_level=2', 'werror=false', 'b_staticpic=false', 'prefix=/' ],
meson_version: '>=0.50.1',
meson_version: '>=0.55.0',
)

debug_options = false
Expand Down
2 changes: 1 addition & 1 deletion meson/part/compiler_args/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ extra_common_flags = [

'-Wall',
'-Wextra',
'-Werror-implicit-function-declaration',
'-Wwrite-strings',
'-Wunknown-pragmas',

Expand Down Expand Up @@ -91,6 +90,7 @@ endif

extra_cflags = extra_common_flags + [
'-Wmissing-prototypes',
'-Werror-implicit-function-declaration',

'-Wno-missing-braces',
'-Wno-missing-field-initializers',
Expand Down
6 changes: 3 additions & 3 deletions meson/part/extra_targets/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ run_target('config',
'-c', 'cd $1 && $2 $3 $4 $5',
'--',
meson.build_root(),
config_py.path(),
config_py.full_path(),
meson.source_root() / 'HelenOS.config',
meson.source_root() / 'defaults',
'--mask-platform',
Expand All @@ -50,7 +50,7 @@ if false
'-c', 'cd $1 && $2 $3 $4 random',
'--',
meson.build_root(),
config_py.path(),
config_py.full_path(),
meson.source_root() / 'HelenOS.config',
meson.source_root() / 'defaults',
]
Expand All @@ -76,7 +76,7 @@ if doxygen.found()
'-c', 'cd $1 && $2 $3',
'--',
meson.source_root() / 'doxygen',
doxygen.path(),
doxygen.full_path(),
_dox_cfg,
])
endif
Expand Down
14 changes: 5 additions & 9 deletions uspace/app/wifi_supplicant/wifi_supplicant.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,11 @@ static void print_syntax(void)
printf("\tdisconnect <index> - disconnect from network\n");
}

static char *nic_addr_format(nic_address_t *addr)
static void nic_addr_format(nic_address_t *addr, char *out, size_t out_size)
{
char *str;
int rc = asprintf(&str, "%02x:%02x:%02x:%02x:%02x:%02x",
snprintf(out, out_size, "%02x:%02x:%02x:%02x:%02x:%02x",
addr->address[0], addr->address[1], addr->address[2],
addr->address[3], addr->address[4], addr->address[5]);

if (rc < 0)
return NULL;

return str;
}

static errno_t get_wifi_list(service_id_t **wifis, size_t *count)
Expand Down Expand Up @@ -262,9 +256,11 @@ static errno_t wifi_scan(uint32_t index, bool now)

for (uint8_t i = 0; i < scan_results.length; i++) {
ieee80211_scan_result_t result = scan_results.results[i];
char mac_addr_hex[18];
nic_addr_format(&result.bssid, mac_addr_hex, 18);

printf("%16.16s %17s %4d %5s %5s %7s %7s\n",
result.ssid, nic_addr_format(&result.bssid),
result.ssid, mac_addr_hex,
result.channel,
enum_name(ieee80211_security_type_strs, result.security.type),
enum_name(ieee80211_security_auth_strs, result.security.auth),
Expand Down
12 changes: 6 additions & 6 deletions uspace/drv/nic/ar9271/wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ errno_t wmi_send_command(htc_device_t *htc_device, wmi_command_t command_id,
sizeof(htc_frame_header_t);
size_t buffer_size = header_size + command_length;
void *buffer = malloc(buffer_size);
if (buffer == NULL) {
usb_log_error("Failed to allocate WMI message buffer (out of memory).\n");
return ENOMEM;
}

if (command_buffer != NULL)
memcpy(buffer + header_size, command_buffer, command_length);
Expand All @@ -240,17 +244,15 @@ errno_t wmi_send_command(htc_device_t *htc_device, wmi_command_t command_id,
wmi_header->sequence_number =
host2uint16_t_be(++htc_device->sequence_number);

/* Send message. */
/* Send message (buffer will not be needed afterwards regardless of result). */
errno_t rc = htc_send_control_message(htc_device, buffer, buffer_size,
htc_device->endpoints.wmi_endpoint);
free(buffer);
if (rc != EOK) {
free(buffer);
usb_log_error("Failed to send WMI message. Error: %s\n", str_error_name(rc));
return rc;
}

free(buffer);

bool clean_resp_buffer = false;
size_t response_buffer_size =
htc_device->ath_device->ctrl_response_length;
Expand All @@ -266,15 +268,13 @@ errno_t wmi_send_command(htc_device_t *htc_device, wmi_command_t command_id,
rc = htc_read_control_message(htc_device, response_buffer,
response_buffer_size, NULL);
if (rc != EOK) {
free(buffer);
usb_log_error("Failed to receive WMI message response. "
"Error: %s\n", str_error_name(rc));
return rc;
}

if (response_buffer_size < sizeof(htc_frame_header_t) +
sizeof(wmi_command_header_t)) {
free(buffer);
usb_log_error("Corrupted response received.\n");
return EINVAL;
}
Expand Down
4 changes: 2 additions & 2 deletions uspace/lib/cpp/include/__bits/adt/hash_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ namespace std::aux

void swap(hash_table& other)
noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
noexcept(swap(declval<Hasher&>(), declval<Hasher&>())) &&
noexcept(swap(declval<KeyEq&>(), declval<KeyEq&>())))
noexcept(std::swap(declval<Hasher&>(), declval<Hasher&>())) &&
noexcept(std::swap(declval<KeyEq&>(), declval<KeyEq&>())))
{
std::swap(table_, other.table_);
std::swap(bucket_count_, other.bucket_count_);
Expand Down
2 changes: 1 addition & 1 deletion uspace/lib/cpp/include/__bits/adt/rbtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ namespace std::aux

void swap(rbtree& other)
noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
noexcept(swap(declval<KeyComp&>(), declval<KeyComp&>())))
noexcept(std::swap(declval<KeyComp&>(), declval<KeyComp&>())))
{
std::swap(root_, other.root_);
std::swap(size_, other.size_);
Expand Down
4 changes: 2 additions & 2 deletions uspace/lib/cpp/include/__bits/string/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ namespace std
}

basic_string(size_type n, value_type c, const allocator_type& alloc = allocator_type{})
: data_{}, size_{n}, capacity_{n}, allocator_{alloc}
: data_{}, size_{n}, capacity_{n + 1}, allocator_{alloc}
{
data_ = allocator_.allocate(capacity_);
for (size_type i = 0; i < size_; ++i)
Expand Down Expand Up @@ -907,7 +907,7 @@ namespace std
basic_string& assign(const value_type* str, size_type n)
{
// TODO: if (n > max_size()) throw length_error.
resize_without_copy_(n);
resize_without_copy_(n + 1);
traits_type::copy(begin(), str, n);
size_ = n;
ensure_null_terminator_();
Expand Down
1 change: 1 addition & 0 deletions uspace/lib/cpp/src/__bits/unwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <typeinfo>

namespace __cxxabiv1
{
Expand Down
11 changes: 10 additions & 1 deletion uspace/lib/cpp/src/future.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ namespace std

const char* future_error::what() const noexcept
{
return code().message().c_str();
/*
* FIXME
* Following code would be optimal but the message string is
* actually destroyed before the function returns so we would
* be returning a dangling pointer. No simple fix available, hence
* we use the ugly hack.
*/
//return code().message().c_str();
#define QUOTE_ARG(arg) #arg
return "future_error, see " __FILE__ ":" QUOTE_ARG(__LINE__);
}
}
2 changes: 1 addition & 1 deletion uspace/lib/ui/test/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ PCUT_TEST(send_kbd)
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(window);

kbd_event.type = POS_PRESS;
kbd_event.type = KEY_PRESS;
kbd_event.key = KC_X;
kbd_event.mods = 0;
kbd_event.c = 'x';
Expand Down
2 changes: 1 addition & 1 deletion uspace/lib/usbdev/include/usb/dev/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ usb_endpoint_mapping_t *usb_device_get_mapped_ep_desc(usb_device_t *,
int usb_device_unmap_ep(usb_endpoint_mapping_t *);

usb_address_t usb_device_get_address(const usb_device_t *);
usb_speed_t usb_device_get_depth(const usb_device_t *);
unsigned usb_device_get_depth(const usb_device_t *);
usb_speed_t usb_device_get_speed(const usb_device_t *);
int usb_device_get_iface_number(const usb_device_t *);
devman_handle_t usb_device_get_devman_handle(const usb_device_t *);
Expand Down
11 changes: 10 additions & 1 deletion uspace/srv/hid/output/proto/vt100.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@
#include <types/common.h>
#include "vt100.h"

#define MAX_CONTROL 20
/** Buffer size when creating actual VT100 commands.
*
* This is absurdly large but since we accept numbers via sysarg_t,
* we make it big enough for the largest value to be on the safe side
* (and to silence compiler too).
*
* TODO: find out if VT100 has some hard limits or perhaps simply cut-out
* values larger than 16 bits or something.
*/
#define MAX_CONTROL 64

typedef enum {
CI_BLACK = 0,
Expand Down

0 comments on commit f4a4266

Please sign in to comment.