Ignore:
Timestamp:
2010-03-23T22:58:44Z (14 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5814ef7
Parents:
76ca3f7
Message:

IPC_[SG]ET_ARG macros refactored to be more explicit and safer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/socket/socket_messages.h

    r76ca3f7 re417b96  
    115115 *  @param[out] answer The message answer structure.
    116116 */
    117 #define SOCKET_SET_SOCKET_ID(answer)            &IPC_GET_ARG1(answer)
     117#define SOCKET_SET_SOCKET_ID(answer, value) \
     118        {ipcarg_t argument = (value); IPC_SET_ARG1(answer, argument);}
    118119
    119120/** Returns the socket identifier message parameter.
    120121 *  @param[in] call The message call structure.
    121122 */
    122 #define SOCKET_GET_SOCKET_ID(call)              (int) IPC_GET_ARG1(call)
     123#define SOCKET_GET_SOCKET_ID(call) \
     124        ({int socket_id = (int) IPC_GET_ARG1(call); socket_id;})
    123125
    124126/** Sets the read data length in the message answer.
    125127 *  @param[out] answer The message answer structure.
    126128 */
    127 #define SOCKET_SET_READ_DATA_LENGTH(answer)     &IPC_GET_ARG1(answer)
     129#define SOCKET_SET_READ_DATA_LENGTH(answer, value) \
     130        {ipcarg_t argument = (value); IPC_SET_ARG1(answer, argument);}
    128131
    129132/** Returns the read data length message parameter.
    130133 *  @param[in] call The message call structure.
    131134 */
    132 #define SOCKET_GET_READ_DATA_LENGTH(call)       (int) IPC_GET_ARG1(call)
     135#define SOCKET_GET_READ_DATA_LENGTH(call) \
     136        ({int data_length = (int) IPC_GET_ARG1(call); data_length;})
    133137
    134138/** Returns the backlog message parameter.
    135139 *  @param[in] call The message call structure.
    136140 */
    137 #define SOCKET_GET_BACKLOG(call)                (int) IPC_GET_ARG2(call)
     141#define SOCKET_GET_BACKLOG(call) \
     142        ({int backlog = (int) IPC_GET_ARG2(call); backlog;})
    138143
    139144/** Returns the option level message parameter.
    140145 *  @param[in] call The message call structure.
    141146 */
    142 #define SOCKET_GET_OPT_LEVEL(call)              (int) IPC_GET_ARG2(call)
     147#define SOCKET_GET_OPT_LEVEL(call) \
     148        ({int opt_level = (int) IPC_GET_ARG2(call); opt_level;})
    143149
    144150/** Returns the data fragment size message parameter.
    145151 *  @param[in] call The message call structure.
    146152 */
    147 #define SOCKET_GET_DATA_FRAGMENT_SIZE(call)     (size_t) IPC_GET_ARG2(call)
     153#define SOCKET_GET_DATA_FRAGMENT_SIZE(call) \
     154        ({size_t size = (size_t) IPC_GET_ARG2(call); size;})
    148155
    149156/** Sets the data fragment size in the message answer.
    150157 *  @param[out] answer The message answer structure.
    151158 */
    152 #define SOCKET_SET_DATA_FRAGMENT_SIZE(answer)   &IPC_GET_ARG2(answer)
     159#define SOCKET_SET_DATA_FRAGMENT_SIZE(answer, value) \
     160        {ipcarg_t argument = (value); IPC_SET_ARG2(answer, argument);}
    153161
    154162/** Sets the address length in the message answer.
    155163 *  @param[out] answer The message answer structure.
    156164 */
    157 #define SOCKET_SET_ADDRESS_LENGTH(answer)       &IPC_GET_ARG3(answer)
     165#define SOCKET_SET_ADDRESS_LENGTH(answer, value) \
     166        {ipcarg_t argument = (value); IPC_SET_ARG3(answer, argument);}
    158167
    159168/** Returns the address length message parameter.
    160169 *  @param[in] call The message call structure.
    161170 */
    162 #define SOCKET_GET_ADDRESS_LENGTH(call)         (socklen_t) IPC_GET_ARG3(call)
     171#define SOCKET_GET_ADDRESS_LENGTH(call) \
     172        ({socklen_t address_length = (socklen_t) IPC_GET_ARG3(call); address_length;})
    163173
    164174/** Sets the header size in the message answer.
    165175 *  @param[out] answer The message answer structure.
    166176 */
    167 #define SOCKET_SET_HEADER_SIZE(answer)          &IPC_GET_ARG3(answer)
     177#define SOCKET_SET_HEADER_SIZE(answer, value) \
     178        \
     179        {ipcarg_t argument = (value); IPC_SET_ARG3(answer, argument);}
    168180
    169181/** Returns the header size message parameter.
    170182 *  @param[in] call The message call structure.
    171183 */
    172 #define SOCKET_GET_HEADER_SIZE(call)            (size_t) IPC_GET_ARG3(call)
     184#define SOCKET_GET_HEADER_SIZE(call) \
     185        ({size_t size = (size_t) IPC_GET_ARG3(call); size;})
    173186
    174187/** Returns the flags message parameter.
    175188 *  @param[in] call The message call structure.
    176189 */
    177 #define SOCKET_GET_FLAGS(call)                  (int) IPC_GET_ARG4(call)
     190#define SOCKET_GET_FLAGS(call) \
     191        ({int flags = (int) IPC_GET_ARG4(call); flags;})
    178192
    179193/** Returns the option name message parameter.
    180194 *  @param[in] call The message call structure.
    181195 */
    182 #define SOCKET_GET_OPT_NAME(call)               (int) IPC_GET_ARG4(call)
     196#define SOCKET_GET_OPT_NAME(call) \
     197        ({int opt_name = (int) IPC_GET_ARG4(call); opt_name;})
    183198
    184199/** Returns the data fragments message parameter.
    185200 *  @param[in] call The message call structure.
    186201 */
    187 #define SOCKET_GET_DATA_FRAGMENTS(call)         (int) IPC_GET_ARG5(call)
     202#define SOCKET_GET_DATA_FRAGMENTS(call) \
     203        ({int fragments = (int) IPC_GET_ARG5(call); fragments;})
    188204
    189205/** Returns the new socket identifier message parameter.
    190206 *  @param[in] call The message call structure.
    191207 */
    192 #define SOCKET_GET_NEW_SOCKET_ID(call)          (int) IPC_GET_ARG5(call)
     208#define SOCKET_GET_NEW_SOCKET_ID(call) \
     209        ({int socket_id = (int) IPC_GET_ARG5(call); socket_id;})
    193210
    194211/*@}*/
Note: See TracChangeset for help on using the changeset viewer.