On 27/08/14 06:48, Timothy Gu wrote: > On Tue, Aug 26, 2014 at 9:12 PM, Luca Barbato <lu_z...@gentoo.org> wrote: > >> +static int xcbgrab_frame_shm(AVFormatContext *s, AVPacket *pkt) >> +{ >> + XCBGrabContext *c = s->priv_data; >> + xcb_shm_get_image_cookie_t iq; >> + xcb_shm_get_image_reply_t *img; >> + xcb_drawable_t drawable = c->screen->root; >> + uint8_t *data; >> + int size = c->frame_size + FF_INPUT_BUFFER_PADDING_SIZE; >> + int id = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777); >> + xcb_generic_error_t *e = NULL; >> + >> + if (id == -1) { >> + char errbuf[1024]; >> + av_strerror(AVERROR(errno), errbuf, sizeof(errbuf)); >> + av_log(s, AV_LOG_ERROR, "shmget %d failed: %s\n", size, errbuf); >> + return AVERROR(ENOMEM); > > Does this have to be ENOMEM? Better return AVERROR(errno).
Can be done. >> +#if HAVE_SYS_SHM_H >> + if (c->has_shm && xcbgrab_frame_shm(s, pkt) < 0) >> + c->has_shm = 0; >> +#endif >> + if (!c->has_shm) >> + ret = xcbgrab_frame(s, pkt); > > Unchecked return code > >> + >> + if (c->draw_mouse) >> + ret = xcbgrab_draw_mouse(s, pkt, p, geo); actually this one should be void (failure in drawing the mouse is considered secondary). >> + >> +static av_cold int xcbgrab_read_header(AVFormatContext *s) >> +{ >> + XCBGrabContext *c = s->priv_data; >> + int screen_num, ret; >> + const xcb_setup_t *setup; >> + >> + c->conn = xcb_connect(s->filename, &screen_num); >> + if ((ret = xcb_connection_has_error(c->conn))) { >> + av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d\n", >> + s->filename ? s->filename : "default", ret); >> + return AVERROR(EIO); >> + } >> + setup = xcb_get_setup(c->conn); >> + >> + c->screen = get_screen(setup, screen_num); >> + if (!c->screen) { >> + av_log(s, AV_LOG_ERROR, "The screen %d does not exist.\n", >> + screen_num); > > Missing return? Yes! Thanks for spotting. >> + if (c->draw_mouse) { >> + if (!(c->draw_mouse = check_xfixes(c->conn))) { >> + av_log(s, AV_LOG_WARNING, >> + "XFixes not available, cannot draw the mouse.\n"); >> + } >> + if (c->bpp < 24) { >> + avpriv_report_missing_feature(s, "%d bits per pixel screen", >> + c->bpp); >> + c->draw_mouse = 0; > > Ditto? No, it is a fallback _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel