Bug 110897 - bad source code
bad source code
Product: Fedora
Classification: Fedora
Component: ncpfs (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Karsten Hopp
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2003-11-25 07:24 EST by d.binderman
Modified: 2007-11-30 17:10 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-02-02 05:58:26 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description d.binderman 2003-11-25 07:24:31 EST
Description of problem:

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

The compiler said


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.


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];
        u_int8_t ServerName[49];

Array limits in C are exclusive, not inclusive.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
Actual results:

Expected results:

Additional info:
Comment 1 Petr Vandrovec 2004-02-01 19:23:28 EST
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 05:24:57 EST
>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 05:58:26 EST
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) 

Note You need to log in before you can comment on or make changes to this bug.