Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 06599a1 in mainline


Ignore:
Timestamp:
2020-03-06T19:13:55Z (4 weeks ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
3529f148
Parents:
22d990c
git-author:
Matthieu Riolo <matthieu.riolo@…> (2020-02-05 21:48:41)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2020-03-06 19:13:55)
Message:

Correcting sysctl list-units

One failure was a cast in lib/sysman/src/ctl.c which wrongly used
an enum like a pointer of the type sysarg_t. This resulted into a
memory allocation failure.

The second bug was in the loop of sysctl. For iterating over all
found units the difference was created of two pointers and then
compared to an unsigned int which was down casted to an int.
Unnecessary complicated and a source for casting problems.
It has been replaced with a simple for-loop and an array access

Location:
uspace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sysctl/main.c

    r22d990c r06599a1  
    7676        }
    7777
    78         for (unit_handle_t *it = units; it - units < (int)unit_cnt; ++it) {
     78        for (size_t i = 0; i < unit_cnt; i++) {
     79                unit_handle_t handle = units[i];
    7980                char name[NAME_BUFFER];
    8081                unit_state_t state;
    8182
    82                 rc = sysman_unit_get_name(*it, name, NAME_BUFFER);
     83                rc = sysman_unit_get_name(handle, name, NAME_BUFFER);
    8384                if (rc != EOK)
    8485                        goto fail;
    8586
    86                 rc = sysman_unit_get_state(*it, &state);
     87                rc = sysman_unit_get_state(handle, &state);
    8788                if (rc != EOK)
    8889                        goto fail;
  • uspace/lib/sysman/src/ctl.c

    r22d990c r06599a1  
    186186errno_t sysman_unit_get_state(unit_handle_t handle, unit_state_t *state)
    187187{
    188         async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL);
    189         errno_t rc = async_req_1_1(exch, SYSMAN_CTL_UNIT_GET_STATE, handle, (sysarg_t *)state);
    190         sysman_exchange_end(exch);
     188        sysarg_t ret;
     189        async_exch_t *exch = sysman_exchange_begin(SYSMAN_PORT_CTL);
     190        errno_t rc = async_req_1_1(exch, SYSMAN_CTL_UNIT_GET_STATE, handle, &ret);
     191        sysman_exchange_end(exch);
     192        *state = (unit_state_t)ret;
    191193
    192194        return rc;
Note: See TracChangeset for help on using the changeset viewer.