From: Philip Homburg Date: Fri, 22 Feb 2008 15:56:12 +0000 (+0000) Subject: Declare and call functions that check arguments and return a status code. X-Git-Tag: v3.1.4~257 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch09.html?a=commitdiff_plain;h=fecd153c2c949a5f05b30a940b8b03a391041b92;p=minix.git Declare and call functions that check arguments and return a status code. --- diff --git a/drivers/pci/main.c b/drivers/pci/main.c index 1b44afe6d..213fe921c 100644 --- a/drivers/pci/main.c +++ b/drivers/pci/main.c @@ -24,7 +24,6 @@ FORWARD _PROTOTYPE( void do_find_dev, (message *mp) ); FORWARD _PROTOTYPE( void do_ids, (message *mp) ); FORWARD _PROTOTYPE( void do_dev_name, (message *mp) ); FORWARD _PROTOTYPE( void do_dev_name_s, (message *mp) ); -FORWARD _PROTOTYPE( void do_slot_name, (message *mp) ); FORWARD _PROTOTYPE( void do_slot_name_s, (message *mp) ); FORWARD _PROTOTYPE( void do_set_acl, (message *mp) ); FORWARD _PROTOTYPE( void do_del_acl, (message *mp) ); @@ -64,7 +63,6 @@ int main(void) case BUSC_PCI_FIND_DEV: do_find_dev(&m); break; case BUSC_PCI_IDS: do_ids(&m); break; case BUSC_PCI_DEV_NAME: do_dev_name(&m); break; - case BUSC_PCI_SLOT_NAME: do_slot_name(&m); break; case BUSC_PCI_RESERVE: do_reserve(&m); break; case BUSC_PCI_ATTR_R8: do_attr_r8(&m); break; case BUSC_PCI_ATTR_R16: do_attr_r16(&m); break; @@ -189,10 +187,16 @@ message *mp; devind= mp->m1_i1; - pci_ids(devind, &vid, &did); + r= pci_ids_s(devind, &vid, &did); + if (r != OK) + { + printf("pci:do_ids: failed for devind %d: %d\n", + devind, r); + } + mp->m1_i1= vid; mp->m1_i2= did; - mp->m_type= OK; + mp->m_type= r; r= send(mp->m_source, mp); if (r != 0) { @@ -275,34 +279,6 @@ message *mp; } } -PRIVATE void do_slot_name(mp) -message *mp; -{ - int r, devind, name_len, len; - char *name_ptr, *name; - - devind= mp->m1_i1; - name_len= mp->m1_i2; - name_ptr= mp->m1_p1; - - name= pci_slot_name(devind); - - len= strlen(name)+1; - if (len > name_len) - len= name_len; - printf("PCI: pci`do_slot_name: calling do_vircopy\n"); - r= sys_vircopy(SELF, D, (vir_bytes)name, mp->m_source, D, - (vir_bytes)name_ptr, len); - - mp->m_type= r; - r= send(mp->m_source, mp); - if (r != 0) - { - printf("PCI: do_slot_name: unable to send to %d: %d\n", - mp->m_source, r); - } -} - PRIVATE void do_slot_name_s(mp) message *mp; { @@ -314,12 +290,21 @@ message *mp; name_len= mp->m1_i2; gid= mp->m1_i3; - name= pci_slot_name(devind); + r= pci_slot_name_s(devind, &name); + if (r != OK) + { + printf("pci:do_slot_name_s: failed for devind %d: %d\n", + devind, r); + } - len= strlen(name)+1; - if (len > name_len) - len= name_len; - r= sys_safecopyto(mp->m_source, gid, 0, (vir_bytes)name, len, D); + if (r == OK) + { + len= strlen(name)+1; + if (len > name_len) + len= name_len; + r= sys_safecopyto(mp->m_source, gid, 0, + (vir_bytes)name, len, D); + } mp->m_type= r; r= send(mp->m_source, mp); @@ -437,9 +422,15 @@ message *mp; devind= mp->m2_i1; port= mp->m2_i2; - v= pci_attr_r8(devind, port); + r= pci_attr_r8_s(devind, port, &v); + if (r != OK) + { + printf( + "pci:do_attr_r8: pci_attr_r8_s(%d, %d, ...) failed: %d\n", + devind, port, r); + } mp->m2_l1= v; - mp->m_type= OK; + mp->m_type= r; r= send(mp->m_source, mp); if (r != 0) { @@ -477,7 +468,13 @@ message *mp; devind= mp->m2_i1; port= mp->m2_i2; - v= pci_attr_r32(devind, port); + r= pci_attr_r32_s(devind, port, &v); + if (r != OK) + { + printf( + "pci:do_attr_r32: pci_attr_r32_s(%d, %d, ...) failed: %d\n", + devind, port, r); + } mp->m2_l1= v; mp->m_type= OK; r= send(mp->m_source, mp); diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 50eab6794..387aca7d7 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -89,6 +89,11 @@ _PROTOTYPE( int pci_first_dev_a, (struct rs_pci *aclp, int *devindp, _PROTOTYPE( int pci_next_dev_a, (struct rs_pci *aclp, int *devindp, u16_t *vidp, u16_t *didp) ); +_PROTOTYPE( int pci_attr_r8_s, (int devind, int port, u8_t *vp) ); +_PROTOTYPE( int pci_attr_r32_s, (int devind, int port, u32_t *vp) ); +_PROTOTYPE( int pci_slot_name_s, (int devind, char **cpp) ); +_PROTOTYPE( int pci_ids_s, (int devind, u16_t *vidp, u16_t *didp) ); + /* * $PchId: pci.h,v 1.4 2001/12/06 20:21:22 philip Exp $ */