Mailinglist Archive: opensuse-commit (2092 mails)

< Previous Next >
commit NetworkManager-kde
  • From: root@xxxxxxxxxxxxxxx (h_root)
  • Date: Fri, 24 Aug 2007 01:48:26 +0200
  • Message-id: <20070823234826.9ABEA678180@xxxxxxxxxxxxxxx>

Hello community,

here is the log from the commit of package NetworkManager-kde
checked in at Fri Aug 24 01:48:26 CEST 2007.

--------
--- KDE/NetworkManager-kde/NetworkManager-kde.changes   2007-08-09 11:57:20.000000000 +0200
+++ /mounts/work_src_done/STABLE/NetworkManager-kde/NetworkManager-kde.changes  2007-08-22 13:16:38.000000000 +0200
@@ -1,0 +2,5 @@
+Wed Aug 22 13:16:22 CEST 2007 - dmueller@xxxxxxx
+
+- fix various memory corruptions, memory leaks and other bugs 
+
+-------------------------------------------------------------------

Old:
----
  knetworkmanager-fixbuild_u64-hschaa-01.patch

New:
----
  r690178.diff
  r703269.diff
  r703272.diff
  r703275.diff
  r703276.diff
  r703278.diff
  r703279.diff
  r703280.diff
  r703282.diff

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ NetworkManager-kde.spec ++++++
--- /var/tmp/diff_new_pack.U15864/_old  2007-08-24 01:48:17.000000000 +0200
+++ /var/tmp/diff_new_pack.U15864/_new  2007-08-24 01:48:17.000000000 +0200
@@ -20,7 +20,7 @@
 Group:          System/GUI/KDE
 Autoreqprov:    on
 Version:        0.2r674918
-Release:        22
+Release:        31
 Summary:        KNetworkManager application for use with NetworkManager
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 Requires:       NetworkManager
@@ -32,10 +32,18 @@
 Patch2:         fix-desktop-icon.diff
 Patch3:         knetworkmanager-version-hschaa-01.patch
 Patch4:         knetworkmanager-fixnetworksui-hschaa-01.patch
-Patch5:         knetworkmanager-fixbuild_u64-hschaa-01.patch
 Patch6:         knetworkmanager-enablebutton-hschaa-01.patch
 Patch7:         knetworkmanager-show_message-hschaa-01.patch
 Patch8:         knetworkmanager-infodialog_tab-hschaa-01.patch
+Patch9:         r703269.diff
+Patch10:        r703272.diff
+Patch11:        r703275.diff
+Patch12:        r703276.diff
+Patch13:        r703278.diff
+Patch14:        r703279.diff
+Patch15:        r703280.diff
+Patch16:        r703282.diff
+Patch17:        r690178.diff
 
 %description
 KNetworkManager is a system tray applet for controlling network
@@ -106,10 +114,18 @@
 %patch0
 %patch3
 %patch4
-%patch5
 %patch6
 %patch7
 %patch8
+%patch9
+%patch10
+%patch11
+%patch12
+%patch13
+%patch14
+%patch15
+%patch17
+%patch16
 
 %build
 . /etc/opt/kde3/common_options
@@ -173,6 +189,8 @@
 /opt/kde3/share/services/%{appname}_vpnc.desktop
 
 %changelog
+* Wed Aug 22 2007 - dmueller@xxxxxxx
+- fix various memory corruptions, memory leaks and other bugs
 * Thu Aug 09 2007 - hschaa@xxxxxxx
 - add patch knetworkmanager-show_message-hschaa-01.patch
   (fixes b.n.c #264176)


++++++ r690178.diff ++++++
------------------------------------------------------------------------
r690178 | hschaa | 2007-07-20 10:27:03 +0200 (Fri, 20 Jul 2007) | 3 lines

Use nl_handle_alloc instead of nl_handle_alloc_nondefault for getting a
netlink handle

------------------------------------------------------------------------
--- knetworkmanager/src/knetworkmanager-devicestore.cpp
+++ knetworkmanager/src/knetworkmanager-devicestore.cpp
@@ -449,7 +449,7 @@ void DeviceStore::getInterfaceStat()
        struct nl_handle *nlh;
        struct nl_cache *link_cache;
 
-       nlh = nl_handle_alloc_nondefault(NL_CB_DEFAULT);
+       nlh = nl_handle_alloc();
        if (!nlh)
                return;
 
++++++ r703269.diff ++++++
------------------------------------------------------------------------
r703269 | mueller | 2007-08-22 11:08:31 +0200 (Wed, 22 Aug 2007) | 3 lines

- fix memory leak
- remove pointless usleep() calls

------------------------------------------------------------------------
--- knetworkmanager/src/knetworkmanager-encryption.h
+++ knetworkmanager/src/knetworkmanager-encryption.h
@@ -56,7 +56,6 @@ class Encryption : public QObject
          /* either passphrase or key */
          void      setSecrets (const SecretMap&);
          SecretMap getSecrets (void) const;
-         void      addCipher (IEEE_802_11_Cipher* cipher);
 
          bool    hasStoredKey (void) const;
          void    restoreKeyAsync (void);
@@ -84,6 +83,7 @@ class Encryption : public QObject
          friend class Network;
 
          void setNetwork(Network *network);
+          void clearCipherList();
          bool persistKey() const;
          
          SecretMap           _secret;
--- knetworkmanager/src/knetworkmanager-encryption.cpp
+++ knetworkmanager/src/knetworkmanager-encryption.cpp
@@ -33,12 +33,6 @@
 #include "knetworkmanager-storage.h"
 #include <NetworkManager/dbus-helpers.h>
 
-void
-Encryption::addCipher (IEEE_802_11_Cipher* cipher)
-{
-       _cipherList->append (cipher);
-}
-
 bool
 Encryption::isValid (const QString & essid)
 {
@@ -174,15 +168,20 @@ Encryption::Encryption () : _currentCiph
        _we_cipher = -1;
 }
 
+void Encryption::clearCipherList()
+{
+    if (_cipherList)
+        for (CipherList::Iterator it = _cipherList->begin(); it != _cipherList->end(); ++it)
+        {
+            ieee_802_11_cipher_unref(*it);
+            (*it) = NULL;
+        }
+    delete _cipherList;
+}
+
 Encryption::~Encryption ()
 {
-       if (_cipherList)
-               for (CipherList::Iterator it = _cipherList->begin(); it != _cipherList->end(); ++it)
-               {
-                       ieee_802_11_cipher_unref(*it);
-                       (*it) = NULL;
-               }
-       delete _cipherList;
+    clearCipherList();
 }
 
 
@@ -224,6 +223,7 @@ EncryptionNone::setDefaults (void)
 }
 
 EncryptionNone::EncryptionNone ()
+    : Encryption()
 {
 
 }
@@ -327,18 +327,18 @@ EncryptionWEP::setType( WEPType type )
 {
        _type = type;
        _dirty = true;
-       delete _cipherList;
+       clearCipherList();
        _cipherList = new CipherList ();
        
        if (_type == WEP_ASCII) {
-               addCipher (cipher_wep64_ascii_new  ());
-               addCipher (cipher_wep128_ascii_new ());
+               _cipherList->append (cipher_wep64_ascii_new  ());
+               _cipherList->append (cipher_wep128_ascii_new  ());
        } else if (_type == WEP_HEX) {
-               addCipher (cipher_wep64_hex_new  ());
-               addCipher (cipher_wep128_hex_new ());
+               _cipherList->append (cipher_wep64_hex_new  ());
+               _cipherList->append (cipher_wep128_hex_new  ());
        } else if (_type == WEP_PASSPHRASE) {
-               addCipher (cipher_wep64_passphrase_new  ());
-               addCipher (cipher_wep128_passphrase_new ());
+               _cipherList->append (cipher_wep64_passphrase_new  ());
+               _cipherList->append (cipher_wep128_passphrase_new  ());
        }
 }
 
@@ -544,8 +544,8 @@ EncryptionWPAPersonal::getVersion (void)
 EncryptionWPAPersonal::EncryptionWPAPersonal ()
 {
        _cipherList = new CipherList (); 
-       addCipher (cipher_wpa_psk_hex_new ());
-       addCipher (cipher_wpa_psk_passphrase_new ());
+        _cipherList->append (cipher_wpa_psk_hex_new ());
+        _cipherList->append (cipher_wpa_psk_passphrase_new ());
        setDefaults ();
 }
 
++++++ r703272.diff ++++++
------------------------------------------------------------------------
r703272 | mueller | 2007-08-22 11:09:41 +0200 (Wed, 22 Aug 2007) | 4 lines

- fix operator== signature
- remove duplicates from MAC list
- bloat--

------------------------------------------------------------------------
--- knetworkmanager/src/knetworkmanager-network.h
+++ knetworkmanager/src/knetworkmanager-network.h
@@ -44,7 +44,7 @@ class Network : public QObject
          Network ();
          ~Network ();
 
-         bool operator == (Network);
+         bool operator == (const Network&);
 
          void        setObjectPath         (const QString&);
          QString     getObjectPath         (void) const;
@@ -53,7 +53,6 @@ class Network : public QObject
          void        insertHardwareAddress (const QString&, bool isActiveAddress = false);
          void        removeHardwareAddress (const QString&);
          QStringList getHardwareAddresses  (void) const;
-         void        setHardwareAddresses  (const QStringList&);
          QString     getActiveHardwareAddress (void);
          void        setStrength           (int);
          int         getStrength           (void) const;
--- knetworkmanager/src/knetworkmanager-network.cpp
+++ knetworkmanager/src/knetworkmanager-network.cpp
@@ -85,13 +85,6 @@ Network::getHardwareAddresses () const
        return _hw_addresses;
 }
 
-void
-Network::setHardwareAddresses( const QStringList & addresses )
-{
-       _dirty |= (_hw_addresses != addresses);
-       _hw_addresses = addresses;
-}
-
 QString
 Network::getActiveHardwareAddress()
 {
@@ -240,7 +233,7 @@ void Network::setHidden (bool hidden)
 }
 
 bool
-Network::operator == (Network net)
+Network::operator == (const Network& net)
 {
        return (this->getObjectPath () == net.getObjectPath ());
 }
@@ -316,7 +309,11 @@ void Network::restore( KConfigBase * cfg
        defaultTime.setTime_t( 1 ); // invalid time
        setTimestamp( cfg->readDateTimeEntry( "Timestamp", &defaultTime) );
        kdDebug() << "restore read timestamp " << _timeStamp << endl;
-       _hw_addresses = cfg->readListEntry( "HardwareAddresses" );
+        _hw_addresses.clear();
+        QStringList lst = cfg->readListEntry( "HardwareAddresses" );
+        for (QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it)
+            insertHardwareAddress(*it, false);
+
        QString encryption = cfg->readEntry( "Encryption", "none" );
        _trusted = cfg->readBoolEntry( "Trusted", false );
        if ( _encryption ) {
++++++ r703275.diff ++++++
------------------------------------------------------------------------
r703275 | mueller | 2007-08-22 11:11:26 +0200 (Wed, 22 Aug 2007) | 2 lines

- fix a qtimer leak

------------------------------------------------------------------------
--- knetworkmanager/src/knetworkmanager-tray.cpp
+++ knetworkmanager/src/knetworkmanager-tray.cpp
@@ -1110,7 +1110,8 @@ Tray::slotShowConnectionInfo()
        ConnectionInfoDialog* dlg = NULL;
        dlg = dynamic_cast<ConnectionInfoDialog*>(this->child("ConnectionInfoDialog", "ConnectionInfoDialog"));
        if (!dlg)
-               dlg = new ConnectionInfoDialog(_ctx, this, "ConnectionInfoDialog", FALSE);
+               dlg = new ConnectionInfoDialog(_ctx, this, 
+                        "ConnectionInfoDialog", Qt::WDestructiveClose);
 
        // show the dialog
        dlg->show();
++++++ r703276.diff ++++++
------------------------------------------------------------------------
r703276 | mueller | 2007-08-22 11:12:01 +0200 (Wed, 22 Aug 2007) | 3 lines

- make it match the comment
- fix constructor

------------------------------------------------------------------------
--- knetworkmanager/src/knetworkmanager-connectioninfodialog.cpp
+++ knetworkmanager/src/knetworkmanager-connectioninfodialog.cpp
@@ -67,8 +67,9 @@ QSize ConnectionInfoWidgetImpl::minimumS
        return size;
 }
 
-ConnectionInfoDialog::ConnectionInfoDialog(KNetworkManager* ctx, QWidget* parent, const char* name, bool modal, WFlags fl)
-       : KDialogBase(KDialogBase::Plain, fl, parent, name, modal, i18n("Connection Status"), KDialogBase::Ok)
+ConnectionInfoDialog::ConnectionInfoDialog(KNetworkManager* ctx, QWidget* parent, const char* name, WFlags fl)
+       : KDialogBase(KDialogBase::Plain, fl, parent, name, 
+                false /*modal*/, i18n("Connection Status"), KDialogBase::Ok)
 {
        _infoWidget = NULL;
        _ctx = ctx;
@@ -77,7 +78,7 @@ ConnectionInfoDialog::ConnectionInfoDial
        // read proc data every 5 seconds
        QTimer* timer = new QTimer(this, "InterfaceStatisticsTimer");
        connect(timer, SIGNAL(timeout()), _ctx->getDeviceStore(), SLOT(getInterfaceStat()));
-       timer->start(2000);
+       timer->start(5000);
 
        // create info widget and load nice pixmaps
        _infoWidget = new ConnectionInfoWidgetImpl(plainPage());
--- knetworkmanager/src/knetworkmanager-connectioninfodialog.h
+++ knetworkmanager/src/knetworkmanager-connectioninfodialog.h
@@ -45,7 +45,7 @@ class ConnectionInfoDialog : public KDia
 {
        Q_OBJECT
        public:
-         ConnectionInfoDialog(KNetworkManager* ctx, QWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0);
+         ConnectionInfoDialog(KNetworkManager* ctx, QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
          ~ConnectionInfoDialog();
 
        public slots:
++++++ r703278.diff ++++++
------------------------------------------------------------------------
r703278 | mueller | 2007-08-22 11:12:47 +0200 (Wed, 22 Aug 2007) | 2 lines

- fix compiler warnings and some other obvious things

------------------------------------------------------------------------
--- knetworkmanager/src/knetworkmanager-settings.h
+++ knetworkmanager/src/knetworkmanager-settings.h
@@ -43,7 +43,7 @@ class GeneralSettingsWidget : public Gen
 {
        Q_OBJECT
        public:
-         GeneralSettingsWidget(QWidget* parent = 0, char* name = 0);
+         GeneralSettingsWidget(QWidget* parent = 0, const char* name = 0);
          ~GeneralSettingsWidget();
        
        public slots:
@@ -58,7 +58,7 @@ class NetworksConfigWidget : public QWid
 {
        Q_OBJECT
        public:
-         NetworksConfigWidget(KNetworkManager* ctx, QWidget* parent = 0, char* name = 0);
+         NetworksConfigWidget(KNetworkManager* ctx, QWidget* parent = 0, const char* name = 0);
          ~NetworksConfigWidget();
 
        public slots:
@@ -74,7 +74,7 @@ class KNotifyWidget : public KNotifyDial
 {
        Q_OBJECT
        public:
-         KNotifyWidget(QWidget* parent = 0, char* name = 0);
+         KNotifyWidget(QWidget* parent = 0, const char* name = 0);
          ~KNotifyWidget();
 
        public slots:
@@ -86,7 +86,7 @@ class DialupConfigWidget : public QWidge
 {
        Q_OBJECT
        public:
-         DialupConfigWidget(QWidget* parent = 0, char* name = 0);
+         DialupConfigWidget(QWidget* parent = 0, const char* name = 0);
          ~DialupConfigWidget();
 
        public slots:
@@ -97,7 +97,7 @@ class SettingsDialog : public KDialogBas
 {
        Q_OBJECT
        public:
-         SettingsDialog(KNetworkManager* ctx, QWidget* parent, char* name, WFlags fl = 0, bool modal = false, QString caption = QString::null);
+         SettingsDialog(KNetworkManager* ctx, QWidget* parent, const char* name, WFlags fl = 0, bool modal = false, QString caption = QString::null);
          ~SettingsDialog();
 
        private:
--- knetworkmanager/src/knetworkmanager-settings.cpp
+++ knetworkmanager/src/knetworkmanager-settings.cpp
@@ -52,7 +52,7 @@
   GeneralSettingsWidget
 */
 
-GeneralSettingsWidget::GeneralSettingsWidget(QWidget* parent, char* name)
+GeneralSettingsWidget::GeneralSettingsWidget(QWidget* parent, const char* name)
        : GeneralSetting(parent, name)
 {
        readConfig();
@@ -129,7 +129,7 @@ void GeneralSettingsWidget::discard()
   NetworksConfigWidget
 */
 
-NetworksConfigWidget::NetworksConfigWidget(KNetworkManager* ctx, QWidget* parent, char* name)
+NetworksConfigWidget::NetworksConfigWidget(KNetworkManager* ctx, QWidget* parent, const char* name)
        : QWidget(parent, name)
 {
        _ctx = ctx;
@@ -197,7 +197,7 @@ void NetworksConfigWidget::discard()
   KNotifyWidget
 */
 
-KNotifyWidget::KNotifyWidget(QWidget* parent, char * name)
+KNotifyWidget::KNotifyWidget(QWidget* parent, const char * name)
        : KNotifyDialog(parent, name, false)
 {
        // we want us displayed in our parent
@@ -230,7 +230,7 @@ void KNotifyWidget::discard()
 /*
   Dialup Connections
 */
-DialupConfigWidget::DialupConfigWidget(QWidget* parent, char* name)
+DialupConfigWidget::DialupConfigWidget(QWidget* parent, const char* name)
        : QWidget(parent, name)
 {
        QGridLayout* layout = new QGridLayout(this, 2, 2);
@@ -267,7 +267,7 @@ void DialupConfigWidget::configureDialup
   SettingsDialog
 */
 
-SettingsDialog::SettingsDialog(KNetworkManager* ctx, QWidget* parent, char* name, WFlags fl, bool modal, QString caption)
+SettingsDialog::SettingsDialog(KNetworkManager* ctx, QWidget* parent, const char* name, WFlags fl, bool modal, QString caption)
        : KDialogBase(KDialogBase::IconList, fl, parent, name, modal, caption)
 {
        _ctx = ctx;
@@ -277,7 +277,7 @@ SettingsDialog::SettingsDialog(KNetworkM
 
        // general settings
        page = addVBoxPage(i18n("General Settings"), i18n("General Settings"), KGlobal::instance()->iconLoader()->loadIcon("package_settings", KIcon::NoGroup, KIcon::SizeMedium));
-       GeneralSettingsWidget* general = new GeneralSettingsWidget(page, "gerenal_settings");
+       GeneralSettingsWidget* general = new GeneralSettingsWidget(page, "general_settings");
        connect(this, SIGNAL(okClicked()), general, SLOT(apply()));
        connect(this, SIGNAL(applyClicked()), general, SLOT(apply()));
        connect(this, SIGNAL(cancelClicked()), general, SLOT(discard()));
++++++ r703279.diff ++++++
------------------------------------------------------------------------
r703279 | mueller | 2007-08-22 11:13:14 +0200 (Wed, 22 Aug 2007) | 2 lines

- listen to the compiler, he mentions bugs

------------------------------------------------------------------------
--- knetworkmanager/src/knetworkmanager-notify.cpp
+++ knetworkmanager/src/knetworkmanager-notify.cpp
@@ -90,7 +90,7 @@ ActivationStageNotifyVPN::updateActivati
                }
        }
 
-       if (progress == NM_VPN_ACT_STAGE_FAILED | progress == NM_VPN_ACT_STAGE_DISCONNECTED)
+       if (progress == NM_VPN_ACT_STAGE_FAILED || progress == NM_VPN_ACT_STAGE_DISCONNECTED)
        {
                QString temp("");
                connectionFailure(temp, temp);
++++++ r703280.diff ++++++
------------------------------------------------------------------------
r703280 | mueller | 2007-08-22 11:14:02 +0200 (Wed, 22 Aug 2007) | 3 lines

- fix reads after free()
- fix memory leak

------------------------------------------------------------------------
--- knetworkmanager/src/knetworkmanager-devicestore_dbus.cpp
+++ knetworkmanager/src/knetworkmanager-devicestore_dbus.cpp
@@ -36,11 +36,25 @@
 
 KNetworkManager* DeviceStoreDBus::_ctx = NULL;
 
-typedef struct {
-       Device * dev;
-       const char * active_net_path;
-       const char * signal_name;
-} UpdateCallbackData;
+struct UpdateCallbackData {
+    UpdateCallbackData(Device* _dev,
+                       const char* _active_net_path,
+                       const char* _signal_name)
+    {
+        dev = _dev;
+        active_net_path = qstrdup(_active_net_path);
+        signal_name = qstrdup(_signal_name);
+    }
+    ~UpdateCallbackData()
+    {
+        delete [] active_net_path;
+        delete [] signal_name;
+    }
+
+    Device * dev;
+    char * active_net_path;
+    char * signal_name;
+};
 
 void
 DeviceStoreDBus::activateDialUp (DialUp* dialup)
@@ -360,11 +374,7 @@ DeviceStoreDBus::updateNetwork (const ch
 
        msg = dbus_message_new_method_call (NM_DBUS_SERVICE, net_path, NM_DBUS_INTERFACE_DEVICES, "getProperties");
        if (msg) {
-               cbData = new UpdateCallbackData; 
-               cbData->dev = dev;
-               cbData->active_net_path = active_net_path;
-               cbData->signal_name = signal_name;
-
+               cbData = new UpdateCallbackData(dev, active_net_path, signal_name); 
                dbus_connection_send_with_reply (con, msg, &pcall, -1);
                if (pcall) {
                        dbus_pending_call_set_notify (pcall, DeviceStoreDBus::updateNetworkCallback, cbData, NULL);
++++++ r703282.diff ++++++
------------------------------------------------------------------------
r703282 | mueller | 2007-08-22 11:15:12 +0200 (Wed, 22 Aug 2007) | 3 lines

- fix a 2kb/s memory leak
- some code simplification and code_beauty++

------------------------------------------------------------------------
--- knetworkmanager/src/knetworkmanager-devicestore.h
+++ knetworkmanager/src/knetworkmanager-devicestore.h
@@ -62,7 +62,7 @@ class DeviceStore : public QObject
 
          void        addDialUp     (DialUp*);
          void        removeDialUp  (DialUp*);
-         DialUpList  getDialUpList (void);
+         DialUpList  getDialUpList () const { return _dialUpList; }
 
          void        addDevice       (Device*);
          void        removeDevice    (Device*);
@@ -88,8 +88,7 @@ class DeviceStore : public QObject
          void emitActive         (Device*);
          void emitActivating     (Device*);
          void emitNetworkFound   (Network*);
-         void setStats           (struct nl_object*);
-         static void setStatsCb  (struct nl_object*, void*);
+         void setStats           (struct rtnl_link*);
        signals:
          void deviceStoreChanged (DeviceStore*);
          void strengthChange     (Device*);
--- knetworkmanager/src/knetworkmanager-devicestore.cpp
+++ knetworkmanager/src/knetworkmanager-devicestore.cpp
@@ -45,12 +45,6 @@ DeviceStore::removeDialUp (DialUp* dialu
        _dialUpList.remove (dialup);
 }
 
-DialUpList
-DeviceStore::getDialUpList ()
-{
-       return _dialUpList;
-}
-
 void
 DeviceStore::activateDialUp (DialUp* dialup)
 {
@@ -387,15 +381,9 @@ void DeviceStore::emitNetworkFound( Netw
        emit networkFound( net );
 }
 
-void DeviceStore::setStatsCb(struct nl_object *obj, void *arg)
+void DeviceStore::setStats(struct rtnl_link *obj)
 {
-       DeviceStore* store = (DeviceStore*) arg;
-       store->setStats(obj);
-}
-
-void DeviceStore::setStats(struct nl_object *obj)
-{
-       char* iface = rtnl_link_get_name( (struct rtnl_link*) obj);
+       char* iface = rtnl_link_get_name(obj);
 
        for (DeviceList::Iterator it = _deviceList.begin(); it != _deviceList.end(); ++it)
        {
@@ -410,32 +398,32 @@ void DeviceStore::setStats(struct nl_obj
                                        delta_msecs = 1;
                        }
 
-                       st = rtnl_link_get_stat((struct rtnl_link*)obj, RTNL_LINK_RX_PACKETS);
+                       st = rtnl_link_get_stat(obj, RTNL_LINK_RX_PACKETS);
                        (*it)->setRxPackets(st);
 
-                       st = rtnl_link_get_stat((struct rtnl_link*)obj, RTNL_LINK_RX_BYTES);
+                       st = rtnl_link_get_stat(obj, RTNL_LINK_RX_BYTES);
                        if ((*it)->getRxBytes() > 0)
                                (*it)->setRxBytesPerSec((uint32_t) ((st - (*it)->getRxBytes()) / ((float)delta_msecs / 1000.0)) );
                        (*it)->setRxBytes(st);
 
-                       st = rtnl_link_get_stat((struct rtnl_link*)obj, RTNL_LINK_RX_DROPPED);
+                       st = rtnl_link_get_stat(obj, RTNL_LINK_RX_DROPPED);
                        (*it)->setRxDropped(st);
 
-                       st = rtnl_link_get_stat((struct rtnl_link*)obj, RTNL_LINK_RX_ERRORS);
+                       st = rtnl_link_get_stat(obj, RTNL_LINK_RX_ERRORS);
                        (*it)->setRxErrors(st);
 
-                       st = rtnl_link_get_stat((struct rtnl_link*)obj, RTNL_LINK_TX_PACKETS);
+                       st = rtnl_link_get_stat(obj, RTNL_LINK_TX_PACKETS);
                        (*it)->setTxPackets(st);
 
-                       st = rtnl_link_get_stat((struct rtnl_link*)obj, RTNL_LINK_TX_BYTES);
+                       st = rtnl_link_get_stat(obj, RTNL_LINK_TX_BYTES);
                        if ((*it)->getTxBytes() > 0)
                                (*it)->setTxBytesPerSec((uint32_t) ((st - (*it)->getTxBytes()) / ((float)delta_msecs / 1000.0)) );
                        (*it)->setTxBytes(st);
 
-                       st = rtnl_link_get_stat((struct rtnl_link*)obj, RTNL_LINK_TX_DROPPED);
+                       st = rtnl_link_get_stat(obj, RTNL_LINK_TX_DROPPED);
                        (*it)->setTxDropped(st);
 
-                       st = rtnl_link_get_stat((struct rtnl_link*)obj, RTNL_LINK_TX_ERRORS);
+                       st = rtnl_link_get_stat(obj, RTNL_LINK_TX_ERRORS);
                        (*it)->setTxErrors(st);
 
                        
@@ -444,35 +432,35 @@ void DeviceStore::setStats(struct nl_obj
        }
 }
 
-void DeviceStore::getInterfaceStat()
+static void setStatsCb(struct nl_object *obj, void *arg)
 {
-       struct nl_handle *nlh;
-       struct nl_cache *link_cache;
-
-       nlh = nl_handle_alloc();
-       if (!nlh)
-               return;
+       DeviceStore* store = (DeviceStore*) arg;
+       store->setStats((struct rtnl_link*) obj);
+}
 
-       if (nl_connect(nlh, NETLINK_ROUTE) < 0)
-       {
-               nl_close(nlh);
-               return;
-       }
-       link_cache = rtnl_link_alloc_cache(nlh);
-       if (!link_cache)
-       {
-               nl_close(nlh);
-               nl_handle_destroy(nlh);
-               return;
-       }
+void DeviceStore::getInterfaceStat()
+{
+    struct nl_handle* nlh = nl_handle_alloc ();
+    if (!nlh)
+        return;
+
+    if (!nl_connect (nlh, NETLINK_ROUTE))
+    {
+        struct nl_cache* link_cache = rtnl_link_alloc_cache (nlh);
+        if (link_cache)
+        {
+            // collect the statistcs
+            nl_cache_foreach (link_cache, setStatsCb, (void*)this);
+
+            nl_cache_destroy_and_free (link_cache);
+        }
 
-       // collect the statistcs
-       nl_cache_foreach(link_cache, DeviceStore::setStatsCb, (void*)this);
+        nl_close (nlh);
+    }
 
-       nl_close(nlh);
-       nl_handle_destroy(nlh);
+    nl_handle_destroy (nlh);
 
-       // new statistics
-       commitUpdate();
+    // new statistics
+    commitUpdate();
 }
 #include "knetworkmanager-devicestore.moc"

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Remember to have fun...

---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-commit+help@xxxxxxxxxxxx

< Previous Next >