From 663ed78329141b2fdf87946f17fc6e28290cdc28 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 19 Jul 2013 18:11:19 -0400 Subject: [PATCH 1/3] _pts: Remove unreachable return statements Fixes warning: afs/_pts.pyx:115:8: Unreachable code warning: afs/_pts.pyx:130:8: Unreachable code Signed-off-by: Anders Kaseorg --- afs/_pts.pyx | 2 -- 1 file changed, 2 deletions(-) diff --git a/afs/_pts.pyx b/afs/_pts.pyx index 3c10b70..0dd65ef 100644 --- a/afs/_pts.pyx +++ b/afs/_pts.pyx @@ -112,7 +112,6 @@ cdef class PTEntry: cdef int _ptentry_from_c(PTEntry p_entry, prcheckentry * c_entry) except -1: if p_entry is None: raise TypeError - return -1 p_entry.flags = c_entry.flags p_entry.id = c_entry.id @@ -127,7 +126,6 @@ cdef int _ptentry_from_c(PTEntry p_entry, prcheckentry * c_entry) except -1: cdef int _ptentry_to_c(prcheckentry * c_entry, PTEntry p_entry) except -1: if p_entry is None: raise TypeError - return -1 c_entry.flags = p_entry.flags c_entry.id = p_entry.id From 7eedff965777f3d5c8f8ea4fb50148c89a6bf238 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 19 Jul 2013 18:15:40 -0400 Subject: [PATCH 2/3] _util: Remove extern from definitions that are not extern Fixes warning: afs/_util.pyx:15:5: Function 'pioctl_read' previously declared as 'private' warning: afs/_util.pyx:29:5: Function 'pioctl_write' previously declared as 'private' Signed-off-by: Anders Kaseorg --- afs/_util.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afs/_util.pyx b/afs/_util.pyx index 932bdf0..af5e698 100644 --- a/afs/_util.pyx +++ b/afs/_util.pyx @@ -12,7 +12,7 @@ cdef int _init = 0 # pioctl convenience wrappers -cdef extern int pioctl_read(char *dir, afs_int32 op, void *buffer, unsigned short size, afs_int32 follow) except -1: +cdef int pioctl_read(char *dir, afs_int32 op, void *buffer, unsigned short size, afs_int32 follow) except -1: cdef ViceIoctl blob cdef afs_int32 code blob.in_size = 0 @@ -26,7 +26,7 @@ cdef extern int pioctl_read(char *dir, afs_int32 op, void *buffer, unsigned shor pyafs_error(code) return code -cdef extern int pioctl_write(char *dir, afs_int32 op, char *buffer, afs_int32 follow) except -1: +cdef int pioctl_write(char *dir, afs_int32 op, char *buffer, afs_int32 follow) except -1: cdef ViceIoctl blob cdef afs_int32 code blob.cin = buffer From b083d4e98e65008dbc2a17b506b07785c8253ff4 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 19 Jul 2013 18:30:39 -0400 Subject: [PATCH 3/3] PTS.__cinit__: Prevent use of uninitialized security object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, PTS.__cinit__ would leave sc uninitialized when passed an invalid negative sec argument. Fixes afs/_pts.c: In function ‘__pyx_pf_3afs_4_pts_3PTS___cinit__’: afs/_pts.c:2999:56: warning: ‘__pyx_v_sc’ may be used uninitialized in this function [-Wmaybe-uninitialized] (__pyx_v_serverconns[__pyx_v_i]) = rx_NewConnection((__pyx_v_info.hostAddr[__pyx_v_i]).sin_addr.s_addr, (__pyx_v_info.hostAddr[__pyx_v_i]).sin_port, PRSRV, __pyx_v_sc, __pyx_t_9); ^ Signed-off-by: Anders Kaseorg --- afs/_pts.pyx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/afs/_pts.pyx b/afs/_pts.pyx index 0dd65ef..b211b56 100644 --- a/afs/_pts.pyx +++ b/afs/_pts.pyx @@ -225,7 +225,9 @@ cdef class PTS: self.cell = info.name - if sec > 0: + if sec == 0: + sc = rxnull_NewClientSecurityObject() + else: strncpy(prin.cell, info.name, sizeof(prin.cell)) prin.instance[0] = 0 strncpy(prin.name, "afs", sizeof(prin.name)) @@ -235,6 +237,7 @@ cdef class PTS: if sec >= 2: # No really - we wanted authentication pyafs_error(code) + sc = rxnull_NewClientSecurityObject() sec = 0 else: if sec == 3: @@ -244,11 +247,7 @@ cdef class PTS: sc = rxkad_NewClientSecurityObject(level, &token.sessionKey, token.kvno, token.ticketLen, token.ticket) - - if sec == 0: - sc = rxnull_NewClientSecurityObject() - else: - sec = 2 + sec = 2 memset(serverconns, 0, sizeof(serverconns)) for 0 <= i < info.numServers: