diff options
author | Łukasz Stelmach <l.stelmach@samsung.com> | 2023-11-03 11:24:24 +0100 |
---|---|---|
committer | Łukasz Stelmach <l.stelmach@samsung.com> | 2023-11-30 11:14:37 +0100 |
commit | 6cd35050c4753ddecbfa4a91c7dfb6a1afdaae9e (patch) | |
tree | 0be4efae288e2e8f4d1af70be7ed6ae1de71ea07 | |
parent | 63c5ea640d9e4234af8aeb14c44e227b5f3a15d0 (diff) | |
download | libtdm-drm-6cd35050c4753ddecbfa4a91c7dfb6a1afdaae9e.tar.gz libtdm-drm-6cd35050c4753ddecbfa4a91c7dfb6a1afdaae9e.tar.bz2 libtdm-drm-6cd35050c4753ddecbfa4a91c7dfb6a1afdaae9e.zip |
Replace %m with strerror_r()
Due to the useage of clock_gettime() and syscall() function in
TDM_BACKEND_* logging macros errno gets overwritten before %m
is handled by vsnprintf() in dlog.
Note: As of today vsnprintf() in dlog isn't called early enough to
preserve errno value, so avoid using %m even without overengineered
logging macros.
Change-Id: I1f7f8c44b91aade5aa319383454ddb3749ac7204
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
-rw-r--r-- | src/tdm_backend_drm.c | 8 | ||||
-rw-r--r-- | src/tdm_drm_display.c | 91 |
2 files changed, 74 insertions, 25 deletions
diff --git a/src/tdm_backend_drm.c b/src/tdm_backend_drm.c index 5ce3771..dfd3645 100644 --- a/src/tdm_backend_drm.c +++ b/src/tdm_backend_drm.c @@ -296,6 +296,8 @@ _tdm_drm_display_deinitialize(tdm_drm_display *display_data) static hal_tdm_error _tdm_drm_display_initialize(tdm_drm_display *display_data) { + char errno_buf[256] = {0,}; + char *errno_msg; hal_tdm_error ret; #if LIBDRM_MAJOR_VERSION >= 2 && LIBDRM_MINOR_VERSION >= 4 && LIBDRM_MICRO_VERSION >= 47 @@ -309,14 +311,16 @@ _tdm_drm_display_initialize(tdm_drm_display *display_data) display_data->mode_res = drmModeGetResources(display_data->drm_fd); if (!display_data->mode_res) { - TDM_BACKEND_ERR("no drm resource: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("no drm resource: %s", errno_msg); ret = HAL_TDM_ERROR_OPERATION_FAILED; goto failed; } display_data->plane_res = drmModeGetPlaneResources(display_data->drm_fd); if (!display_data->plane_res) { - TDM_BACKEND_ERR("no drm plane resource: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("no drm plane resource: %s", errno_msg); ret = HAL_TDM_ERROR_OPERATION_FAILED; goto failed; } diff --git a/src/tdm_drm_display.c b/src/tdm_drm_display.c index ed1f2c6..ea403b0 100644 --- a/src/tdm_drm_display.c +++ b/src/tdm_drm_display.c @@ -82,6 +82,8 @@ _tdm_drm_display_to_tdm_mode(drmModeModeInfoPtr drm_mode, static hal_tdm_error _tdm_drm_display_get_cur_msc(int fd, int pipe, uint *msc) { + char errno_buf[256] = {0,}; + char *errno_msg; drmVBlank vbl; vbl.request.type = DRM_VBLANK_RELATIVE; @@ -90,7 +92,8 @@ _tdm_drm_display_get_cur_msc(int fd, int pipe, uint *msc) vbl.request.sequence = 0; if (drmWaitVBlank(fd, &vbl)) { - TDM_BACKEND_ERR("get vblank counter failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("get vblank counter failed: %s", errno_msg); *msc = 0; return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -103,6 +106,8 @@ _tdm_drm_display_get_cur_msc(int fd, int pipe, uint *msc) static hal_tdm_error _tdm_drm_display_wait_vblank(int fd, int pipe, uint *target_msc, void *data) { + char errno_buf[256] = {0,}; + char *errno_msg; drmVBlank vbl; vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT; @@ -113,8 +118,9 @@ _tdm_drm_display_wait_vblank(int fd, int pipe, uint *target_msc, void *data) vbl.request.signal = (unsigned long)(uintptr_t)data; if (drmWaitVBlank(fd, &vbl)) { + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); *target_msc = 0; - TDM_BACKEND_ERR("wait vblank failed: %m"); + TDM_BACKEND_ERR("wait vblank failed: %s", errno_msg); return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -147,6 +153,8 @@ _tdm_drm_display_commit_primary_layer(tdm_drm_layer *layer_data, { tdm_drm_display *display_data = layer_data->display_data; tdm_drm_output *output_data = layer_data->output_data; + char errno_buf[256] = {0,}; + char *errno_msg; if (output_data->mode_changed && layer_data->display_buffer_changed) { drmModeModeInfoPtr mode; @@ -169,7 +177,8 @@ _tdm_drm_display_commit_primary_layer(tdm_drm_layer *layer_data, if (drmModeSetCrtc(display_data->drm_fd, output_data->crtc_id, layer_data->display_buffer->fb_id, 0, 0, &output_data->connector_id, 1, mode)) { - TDM_BACKEND_ERR("set crtc failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("set crtc failed: %s", errno_msg); return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -183,7 +192,8 @@ _tdm_drm_display_commit_primary_layer(tdm_drm_layer *layer_data, if (!layer_data->display_buffer) { if (drmModeSetCrtc(display_data->drm_fd, output_data->crtc_id, 0, 0, 0, NULL, 0, NULL)) { - TDM_BACKEND_ERR("unset crtc failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("unset crtc failed: %s", errno_msg); return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -204,7 +214,8 @@ _tdm_drm_display_commit_primary_layer(tdm_drm_layer *layer_data, event_data->user_data = user_data; if (drmModePageFlip(display_data->drm_fd, output_data->crtc_id, layer_data->display_buffer->fb_id, DRM_MODE_PAGE_FLIP_EVENT, event_data)) { - TDM_BACKEND_ERR("pageflip failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("pageflip failed: %s", errno_msg); free(event_data); return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -220,6 +231,8 @@ _tdm_drm_display_commit_layer(tdm_drm_layer *layer_data) { tdm_drm_display *display_data = layer_data->display_data; tdm_drm_output *output_data = layer_data->output_data; + char errno_buf[256] = {0,}; + char *errno_msg; uint32_t fx, fy, fw, fh; int crtc_w; @@ -248,9 +261,11 @@ _tdm_drm_display_commit_layer(tdm_drm_layer *layer_data) if (!layer_data->display_buffer) { if (drmModeSetPlane(display_data->drm_fd, layer_data->plane_id, - output_data->crtc_id, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) - TDM_BACKEND_ERR("unset plane(%d) filed: %m", layer_data->plane_id); + output_data->crtc_id, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) { + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("unset plane(%d) filed: %s", layer_data->plane_id, errno_msg); + } return HAL_TDM_ERROR_NONE; } @@ -265,7 +280,8 @@ _tdm_drm_display_commit_layer(tdm_drm_layer *layer_data) layer_data->info.dst_pos.x, layer_data->info.dst_pos.y, layer_data->info.dst_pos.w, layer_data->info.dst_pos.h, fx, fy, fw, fh) < 0) { - TDM_BACKEND_ERR("set plane(%d) failed: %m", layer_data->plane_id); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("set plane(%d) failed: %s", layer_data->plane_id, errno_msg); return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -977,6 +993,8 @@ drm_output_get_capability(hal_tdm_output *output, hal_tdm_caps_output *caps) drmModeConnectorPtr connector = NULL; drmModeCrtcPtr crtc = NULL; drmModeObjectPropertiesPtr props = NULL; + char errno_buf[256] = {0,}; + char *errno_msg; unsigned int i; hal_tdm_error ret; @@ -1020,16 +1038,18 @@ drm_output_get_capability(hal_tdm_output *output, hal_tdm_caps_output *caps) crtc = drmModeGetCrtc(display_data->drm_fd, output_data->crtc_id); if (!crtc) { + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); ret = HAL_TDM_ERROR_OPERATION_FAILED; - TDM_BACKEND_ERR("get crtc failed: %m\n"); + TDM_BACKEND_ERR("get crtc failed: %s\n", errno_msg); goto failed_get; } props = drmModeObjectGetProperties(display_data->drm_fd, output_data->crtc_id, DRM_MODE_OBJECT_CRTC); if (!props) { + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); ret = HAL_TDM_ERROR_OPERATION_FAILED; - TDM_BACKEND_ERR("get crtc properties failed: %m\n"); + TDM_BACKEND_ERR("get crtc properties failed: %s\n", errno_msg); goto failed_get; } @@ -1073,6 +1093,8 @@ drm_output_set_property(hal_tdm_output *output, unsigned int id, hal_tdm_value v { tdm_drm_output *output_data = output; tdm_drm_display *display_data; + char errno_buf[256] = {0,}; + char *errno_msg; int ret; RETURN_VAL_IF_FAIL(output_data, HAL_TDM_ERROR_INVALID_PARAMETER); @@ -1083,7 +1105,8 @@ drm_output_set_property(hal_tdm_output *output, unsigned int id, hal_tdm_value v output_data->crtc_id, DRM_MODE_OBJECT_CRTC, id, value.u32); if (ret < 0) { - TDM_BACKEND_ERR("set property failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("set property failed: %s", errno_msg); return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -1096,6 +1119,8 @@ drm_output_get_property(hal_tdm_output *output, unsigned int id, hal_tdm_value * tdm_drm_output *output_data = output; tdm_drm_display *display_data; drmModeObjectPropertiesPtr props; + char errno_buf[256] = {0,}; + char *errno_msg; unsigned int i; RETURN_VAL_IF_FAIL(output_data, HAL_TDM_ERROR_INVALID_PARAMETER); @@ -1106,7 +1131,8 @@ drm_output_get_property(hal_tdm_output *output, unsigned int id, hal_tdm_value * props = drmModeObjectGetProperties(display_data->drm_fd, output_data->crtc_id, DRM_MODE_OBJECT_CRTC); if (props == NULL) { - TDM_BACKEND_ERR("get property failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("get property failed: %s", errno_msg); return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -1255,6 +1281,8 @@ drm_output_set_dpms(hal_tdm_output *output, hal_tdm_output_dpms dpms_value) { tdm_drm_output *output_data = output; tdm_drm_display *display_data; + char errno_buf[256] = {0,}; + char *errno_msg; int ret; RETURN_VAL_IF_FAIL(output_data, HAL_TDM_ERROR_INVALID_PARAMETER); @@ -1269,7 +1297,8 @@ drm_output_set_dpms(hal_tdm_output *output, hal_tdm_output_dpms dpms_value) output_data->connector_id, DRM_MODE_OBJECT_CONNECTOR, output_data->dpms_prop_id, dpms_value); if (ret < 0) { - TDM_BACKEND_ERR("set dpms failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("set dpms failed: %s", errno_msg); return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -1284,6 +1313,8 @@ drm_output_get_dpms(hal_tdm_output *output, hal_tdm_output_dpms *dpms_value) tdm_drm_output *output_data = output; tdm_drm_display *display_data; drmModeObjectPropertiesPtr props; + char errno_buf[256] = {0,}; + char *errno_msg; unsigned int i; RETURN_VAL_IF_FAIL(output_data, HAL_TDM_ERROR_INVALID_PARAMETER); @@ -1293,7 +1324,8 @@ drm_output_get_dpms(hal_tdm_output *output, hal_tdm_output_dpms *dpms_value) props = drmModeObjectGetProperties(display_data->drm_fd, output_data->connector_id, DRM_MODE_OBJECT_CONNECTOR); if (props == NULL) { - TDM_BACKEND_ERR("get property failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("get property failed: %s", errno_msg); return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -1416,6 +1448,8 @@ drm_layer_get_capability(tdm_drm_layer *layer, tdm_drm_caps_layer *caps) drmModePlanePtr plane = NULL; drmModeObjectPropertiesPtr props = NULL; unsigned int i, format_count = 0; + char errno_buf[256] = {0,}; + char *errno_msg; hal_tdm_error ret; RETURN_VAL_IF_FAIL(layer_data, HAL_TDM_ERROR_INVALID_PARAMETER); @@ -1426,7 +1460,8 @@ drm_layer_get_capability(tdm_drm_layer *layer, tdm_drm_caps_layer *caps) display_data = layer_data->display_data; plane = drmModeGetPlane(display_data->drm_fd, layer_data->plane_id); if (!plane) { - TDM_BACKEND_ERR("get plane failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("get plane failed: %s", errno_msg); ret = HAL_TDM_ERROR_OPERATION_FAILED; goto failed_get; } @@ -1459,8 +1494,9 @@ drm_layer_get_capability(tdm_drm_layer *layer, tdm_drm_caps_layer *caps) props = drmModeObjectGetProperties(display_data->drm_fd, layer_data->plane_id, DRM_MODE_OBJECT_PLANE); if (!props) { + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); ret = HAL_TDM_ERROR_OPERATION_FAILED; - TDM_BACKEND_ERR("get plane properties failed: %m\n"); + TDM_BACKEND_ERR("get plane properties failed: %s\n", errno_msg); goto failed_get; } @@ -1508,6 +1544,8 @@ drm_layer_set_property(tdm_drm_layer *layer, unsigned int id, hal_tdm_value valu { tdm_drm_layer *layer_data = layer; tdm_drm_display *display_data; + char errno_buf[256] = {0,}; + char *errno_msg; int ret; RETURN_VAL_IF_FAIL(layer_data, HAL_TDM_ERROR_INVALID_PARAMETER); @@ -1518,7 +1556,8 @@ drm_layer_set_property(tdm_drm_layer *layer, unsigned int id, hal_tdm_value valu layer_data->plane_id, DRM_MODE_OBJECT_PLANE, id, value.u32); if (ret < 0) { - TDM_BACKEND_ERR("set property failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("set property failed: %s", errno_msg); return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -1531,6 +1570,8 @@ drm_layer_get_property(tdm_drm_layer *layer, unsigned int id, hal_tdm_value *val tdm_drm_layer *layer_data = layer; tdm_drm_display *display_data; drmModeObjectPropertiesPtr props; + char errno_buf[256] = {0,}; + char *errno_msg; unsigned int i; RETURN_VAL_IF_FAIL(layer_data, HAL_TDM_ERROR_INVALID_PARAMETER); @@ -1541,7 +1582,8 @@ drm_layer_get_property(tdm_drm_layer *layer, unsigned int id, hal_tdm_value *val props = drmModeObjectGetProperties(display_data->drm_fd, layer_data->plane_id, DRM_MODE_OBJECT_PLANE); if (props == NULL) { - TDM_BACKEND_ERR("get property failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("get property failed: %s", errno_msg); return HAL_TDM_ERROR_OPERATION_FAILED; } @@ -1603,8 +1645,8 @@ _tdm_drm_display_cb_destroy_buffer(tbm_surface_h buffer, void *user_data) tdm_drm_display_buffer *display_buffer; tdm_drm_layer *layer_data = NULL; tdm_drm_output *output_data = NULL; - char buf[256] = {0,}; - char *ret_tmp; + char errno_buf[256] = {0,}; + char *errno_msg; if (!user_data) { TDM_BACKEND_ERR("no user_data"); @@ -1632,8 +1674,8 @@ _tdm_drm_display_cb_destroy_buffer(tbm_surface_h buffer, void *user_data) if (display_buffer->fb_id > 0) { if (drmModeRmFB(display_data->drm_fd, display_buffer->fb_id) < 0) { - ret_tmp = strerror_r(errno, buf, sizeof(buf)); - TDM_BACKEND_ERR("rm fb failed: %d(%s,%s)\n", errno, buf, ret_tmp); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("rm fb failed: %s\n", errno_msg); } } @@ -1647,6 +1689,8 @@ static tdm_drm_display_buffer * _tdm_drm_display_create_buffer(tdm_drm_display *display_data, tbm_surface_h buffer, hal_tdm_error *err) { tdm_drm_display_buffer *display_buffer = NULL; + char errno_buf[256] = {0,}; + char *errno_msg; int count, i, ret; display_buffer = calloc(1, sizeof(tdm_drm_display_buffer)); @@ -1697,7 +1741,8 @@ _tdm_drm_display_create_buffer(tdm_drm_display *display_data, tbm_surface_h buff display_buffer->format, display_buffer->handles, display_buffer->pitches, display_buffer->offsets, &display_buffer->fb_id, 0); if (ret < 0) { - TDM_BACKEND_ERR("add fb failed: %m"); + errno_msg = strerror_r(errno, errno_buf, sizeof(errno_buf)); + TDM_BACKEND_ERR("add fb failed: %s", errno_msg); free(display_buffer); if (err) *err = HAL_TDM_ERROR_OPERATION_FAILED; |