On 8/14/2018 6:56 AM, Martin Simmons wrote:
Sorry to say that it doesn't compile on FreeBSD (see below).

The warnings about BSOCK::recv are probably generic and occur in every file.

There is some hack for ENODATA in bsockcore.c, but not in bsock.c.



Compiling bsock.c
In file included from bsock.c:35:
In file included from ../bacula.h:169:
In file included from ../lib/lib.h:51:
./bsock.h:72:12: warning: 'BSOCK::recv' hides overloaded virtual function 
[-Woverloaded-virtual]
    int32_t recv();

Don't know about the missing ENODATA in BSD, but the warning should be checked out.

This warning is where class A defines a virtual function, then class B, derived from A, overrides it, then class C, derived from B, overrides it again, but doesn't override all versions. Easier to explain by example.

class A
{
public:
  virtual bool isvalid(int32_t val) = 0;
  virtual bool isvalid(char c) = 0;
};

class B : public A
{
public:
  virtual bool isvalid(int32_t val) { return c < 0; }
  virtual bool isvalid(char c) { return c < 0; }
};

class C : public B
{
  virtual bool isvalid(char c) { return c > 0; }
};

In class C, there is no isvalid(int32_t val) implementation, so consider the 
following:

bool some_func()
{
   C use_it;
   int32_t val = 1;

   return C.isvalid(val);
}

The some_func() function will return TRUE, not the expected FALSE. This is because the B::isvalid(int32_t) override is hidden to C, hence the warning. C::isvalid() will always be evaluated as the single isvalid() override defined in C.

For sane behavior, where B's overrides of isvalid() are NOT hidden, define C as:

class C : public B
{
public:
   virtual bool isvalid(char c) { return c > 0; }
   using B::isvalid;
};



            ^
./bsockcore.h:140:20: note: hidden overloaded virtual function 
'BSOCKCORE::recv' declared here: different number of
       parameters (1 vs 0)
    virtual int32_t recv(int len);
                    ^
bsock.c:439:20: error: use of undeclared identifier 'ENODATA'
          b_errno = ENODATA;
                    ^
bsock.c:467:23: error: use of undeclared identifier 'ENODATA'
             b_errno = ENODATA;
                       ^
bsock.c:520:17: error: use of undeclared identifier 'ENODATA'
       b_errno = ENODATA;
                 ^
bsock.c:537:20: error: use of undeclared identifier 'ENODATA'
          b_errno = ENODATA;
                    ^
1 warning and 4 errors generated.
gmake[1]: *** [Makefile:183: bsock.lo] Error 1


__Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to