- Address some compiler warnings

- Reduce nesting depth in new_handle dispatches
- Fix segfault in handle_arm_request
epel9
Jarod Wilson 16 years ago
parent 3e099f60f4
commit b5eeebf795

@ -0,0 +1,200 @@
diff -Naurp libraw1394-2.0.0/src/arm.c libraw1394-2.0.0.fix/src/arm.c
--- libraw1394-2.0.0/src/arm.c 2008-07-05 16:08:26.000000000 -0400
+++ libraw1394-2.0.0.fix/src/arm.c 2008-11-20 12:37:05.136821199 -0500
@@ -109,7 +109,6 @@ int ieee1394_arm_set_buf (struct ieee139
size_t length, void *buf)
{
struct raw1394_request req;
- int status;
CLEAR_REQ(&req);
@@ -139,7 +138,6 @@ int ieee1394_arm_get_buf (struct ieee139
size_t length, void *buf)
{
struct raw1394_request req;
- int status;
CLEAR_REQ(&req);
diff -Naurp libraw1394-2.0.0/src/dispatch.c libraw1394-2.0.0.fix/src/dispatch.c
--- libraw1394-2.0.0/src/dispatch.c 2008-11-20 12:36:00.918753368 -0500
+++ libraw1394-2.0.0.fix/src/dispatch.c 2008-11-20 12:42:03.387817813 -0500
@@ -24,36 +24,35 @@ int raw1394_errcode_to_errno(raw1394_err
raw1394handle_t raw1394_new_handle(void)
{
- ieee1394handle_t ieee1394_handle = ieee1394_new_handle();
- fw_handle_t fw_handle = NULL;
- raw1394handle_t handle = NULL;
-
- if (ieee1394_handle) {
- struct raw1394_portinfo port;
- if (ieee1394_get_port_info(ieee1394_handle, &port, 1) < 1) {
- ieee1394_destroy_handle(ieee1394_handle);
- ieee1394_handle = NULL;
- fw_handle = fw_new_handle();
- }
- }
- else {
- fw_handle = fw_new_handle();
- }
- if (ieee1394_handle || fw_handle) {
- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle));
- if (ieee1394_handle && handle) {
- handle->is_fw = 0;
- handle->mode.ieee1394 = ieee1394_handle;
- }
- else if (handle) {
- handle->is_fw = 1;
- handle->mode.fw = fw_handle;
- } else if (fw_handle)
- fw_destroy_handle(fw_handle);
- else if (ieee1394_handle)
- ieee1394_destroy_handle(ieee1394_handle);
+ ieee1394handle_t ieee1394_handle;
+ fw_handle_t fw_handle;
+ raw1394handle_t handle;
+ struct raw1394_portinfo port;
+
+ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle));
+ if (!handle)
+ return NULL;
+
+ ieee1394_handle = ieee1394_new_handle();
+ if (!ieee1394_handle)
+ goto try_fw;
+
+ if (ieee1394_get_port_info(ieee1394_handle, &port, 1) >= 1) {
+ handle->is_fw = 0;
+ handle->mode.ieee1394 = ieee1394_handle;
+ return handle;
+ }
+ ieee1394_destroy_handle(ieee1394_handle);
+try_fw:
+ fw_handle = fw_new_handle();
+ if (fw_handle) {
+ handle->is_fw = 1;
+ handle->mode.fw = fw_handle;
+ return handle;
}
- return handle;
+
+ free(handle);
+ return NULL;
}
void raw1394_destroy_handle(raw1394handle_t handle)
@@ -69,27 +68,30 @@ void raw1394_destroy_handle(raw1394handl
raw1394handle_t raw1394_new_handle_on_port(int port)
{
- ieee1394handle_t ieee1394_handle = ieee1394_new_handle_on_port(port);
- fw_handle_t fw_handle = NULL;
- raw1394handle_t handle = NULL;
+ ieee1394handle_t ieee1394_handle;
+ fw_handle_t fw_handle;
+ raw1394handle_t handle;
+
+ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle));
+ if (!handle)
+ return NULL;
+ ieee1394_handle = ieee1394_new_handle_on_port(port);
if (ieee1394_handle) {
- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle));
- if (handle) {
- handle->is_fw = 0;
- handle->mode.ieee1394 = ieee1394_handle;
- } else
- ieee1394_destroy_handle(ieee1394_handle);
- }
- else if (fw_handle = fw_new_handle_on_port(port)) {
- handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle));
- if (handle) {
- handle->is_fw = 1;
- handle->mode.fw = fw_handle;
- } else
- fw_destroy_handle(fw_handle);
+ handle->is_fw = 0;
+ handle->mode.ieee1394 = ieee1394_handle;
+ return handle;
}
- return handle;
+
+ fw_handle = fw_new_handle_on_port(port);
+ if (fw_handle) {
+ handle->is_fw = 1;
+ handle->mode.fw = fw_handle;
+ return handle;
+ }
+
+ free(handle);
+ return NULL;
}
int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch)
diff -Naurp libraw1394-2.0.0/src/eventloop.c libraw1394-2.0.0.fix/src/eventloop.c
--- libraw1394-2.0.0/src/eventloop.c 2008-07-06 14:41:48.000000000 -0400
+++ libraw1394-2.0.0.fix/src/eventloop.c 2008-11-20 12:38:22.289816445 -0500
@@ -32,7 +32,7 @@ int ieee1394_loop_iterate(struct raw1394
{
struct raw1394_request req;
ieee1394handle_t ihandle = handle->mode.ieee1394;
- int retval = 0, channel;
+ int retval = 0;
while (read(ihandle->fd, &req, sizeof(req)) < 0) {
if (errno != EINTR) return -1;
diff -Naurp libraw1394-2.0.0/src/fw.c libraw1394-2.0.0.fix/src/fw.c
--- libraw1394-2.0.0/src/fw.c 2008-11-20 12:36:00.920753360 -0500
+++ libraw1394-2.0.0.fix/src/fw.c 2008-11-20 12:43:13.017816248 -0500
@@ -773,10 +773,12 @@ handle_arm_request(raw1394handle_t handl
}
rrb->request.generation = fwhandle->reset.generation;
rrb->request.buffer_length = in_length;
+ rrb->request.buffer = rrb->data;
memcpy(rrb->request.buffer, request->data, in_length);
rrb->response.response_code = response.rcode;
rrb->response.buffer_length = response.length;
+ rrb->request.buffer = rrb->data + in_length;
memcpy(rrb->response.buffer,
allocation->data + offset, response.length);
diff -Naurp libraw1394-2.0.0/src/fw-iso.c libraw1394-2.0.0.fix/src/fw-iso.c
--- libraw1394-2.0.0/src/fw-iso.c 2008-11-20 12:36:00.921763895 -0500
+++ libraw1394-2.0.0.fix/src/fw-iso.c 2008-11-20 12:39:35.003793770 -0500
@@ -85,7 +85,8 @@ queue_xmit_packets(raw1394handle_t handl
fw_handle_t fwhandle = handle->mode.fw;
enum raw1394_iso_disposition d;
unsigned char tag, sy;
- int len, cycle = -1;
+ unsigned int len;
+ int cycle = -1;
unsigned int dropped = 0;
if (fwhandle->iso.xmit_handler == NULL)
@@ -258,9 +259,7 @@ int fw_iso_xmit_write(raw1394handle_t ha
unsigned char sy)
{
fw_handle_t fwhandle = handle->mode.fw;
- struct fw_cdev_queue_iso queue_iso;
struct fw_cdev_start_iso start_iso;
- struct fw_cdev_iso_packet *p;
int retval;
if (len > fwhandle->iso.max_packet_size) {
diff -Naurp libraw1394-2.0.0/src/main.c libraw1394-2.0.0.fix/src/main.c
--- libraw1394-2.0.0/src/main.c 2008-07-06 14:50:34.000000000 -0400
+++ libraw1394-2.0.0.fix/src/main.c 2008-11-20 12:40:02.828816470 -0500
@@ -253,9 +253,7 @@ void *raw1394_get_userdata(struct raw139
int ieee1394_get_port_info(struct ieee1394_handle *handle,
struct raw1394_portinfo *pinf, int maxports)
{
- int num;
struct raw1394_request req;
- struct raw1394_khost_list *khl;
CLEAR_REQ(&req);
req.type = RAW1394_REQ_LIST_CARDS;

@ -1,11 +1,12 @@
Summary: Library providing low-level IEEE-1394 access Summary: Library providing low-level IEEE-1394 access
Name: libraw1394 Name: libraw1394
Version: 2.0.0 Version: 2.0.0
Release: 2%{?dist} Release: 3%{?dist}
License: LGPLv2+ License: LGPLv2+
Group: System Environment/Libraries Group: System Environment/Libraries
Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz
Patch0: libraw1394-2.0.0-coverity-prevent-fixes.patch Patch0: libraw1394-2.0.0-coverity-prevent-fixes.patch
Patch1: libraw1394-2.0.0-git-fixes.patch
URL: http://www.linux1394.org/ URL: http://www.linux1394.org/
ExcludeArch: s390 s390x ExcludeArch: s390 s390x
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -29,6 +30,7 @@ Development libraries needed to build applications against libraw1394.
%prep %prep
%setup -q %setup -q
%patch0 -p1 %patch0 -p1
%patch1 -p1
%build %build
%configure --disable-static %configure --disable-static
@ -67,6 +69,11 @@ rm -rf $RPM_BUILD_ROOT
%changelog %changelog
* Thu Nov 20 2008 Jarod Wilson <jarod@redhat.com> - 2.0.0-3
- Address some compiler warnings
- Reduce nesting depth in new_handle dispatches
- Fix segfault in handle_arm_request
* Wed Oct 01 2008 Jarod Wilson <jarod@redhat.com> - 2.0.0-2 * Wed Oct 01 2008 Jarod Wilson <jarod@redhat.com> - 2.0.0-2
- Misc fixes from Erik Hovland, based on coverity prevent analysis - Misc fixes from Erik Hovland, based on coverity prevent analysis

Loading…
Cancel
Save