Bug 110897

Summary: bad source code
Product: [Fedora] Fedora Reporter: d.binderman
Component: ncpfsAssignee: Karsten Hopp <karsten>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 1CC: d.binderman
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-02-02 10:58:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description d.binderman 2003-11-25 12:24:31 UTC
Description of problem:

I just tried to compile package ncpfs-2_2_3-1 from Fedora.

The compiler said

1.

ncplib.c(2341): error: expected a ";"
        static int get_argument(int arg_no, const char **target) {

The source code is

struct ncp_conn *
ncp_initialize_2(int *argc, char **argv, int login_necessary,
                 int login_type, long *err, int required)
{
        const char *server = NULL;
        const char *user = NULL;
        const char *password = NULL;
        const char *address = NULL;
        struct ncp_conn_spec spec;
        struct ncp_conn *conn;
        int i = 1;
        NWCCODE nwerr;

        static int get_argument(int arg_no, const char **target) {
                int count = 1;


Nested functions are not supported in ISO C.

Suggest move definition of get_argument outside ncp_initialize_2
to conform with ISO C.

2.

The compiler also said

ncplib.c(2720): warning #175: subscript out of range

The source code is

                target->ServerName[49] = 0;

but in file BUILD/ncpfs-2.2.3/include/ncp/ncplib.h

struct ncp_file_server_info_2 {
#ifdef SWIG
        fixedArray ServerName[49];
#else
        u_int8_t ServerName[49];
#endif

Array limits in C are exclusive, not inclusive.



Version-Release number of selected component (if applicable):
ncpfs-2_2_3-1 

How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Petr Vandrovec 2004-02-02 00:23:28 UTC
Fix for (2) is available at bk://ncpfs.bkbits.net/ncpfs. (1) is won't
fix for me (ncpfs upstream maintainer), unless gcc is going to not
support nested functions. get_argument references couple of variables
local to ncp_initialize_2 function, and I see no reason for jumping
through hoops just to accomodate ISO C.


Comment 2 d.binderman 2004-02-02 10:24:57 UTC
>I see no reason for jumping through hoops just to accomodate ISO C.

1. Using ISO C means you can get the benefits of using a different,
better, compiler on your code. This could mean better warnings,
or it could mean better code generation.

2. There are lots of software development tools, like Insure++
and various code metrics tools, which read & understand ISO C.

By using nested functions, you prevent their use.

3. By using ISO C, you make it easier for the product to be ported
onto new machines.



Comment 3 Karsten Hopp 2004-02-02 10:58:26 UTC
I agree with Petr here. The first part needs to be fixed upstream, 
this isn't the right place to report such bugs. All compilers 
supported by Red Hat compile this package without problems. 
The second part is fixed in ncpfs-2_2_3-3 (Fedora development)