[Rpm-maint] [PATCH] Moving notify flag setting to a common place.

Rakesh Pandit rakesh.pandit at gmail.com
Mon Jan 19 17:33:17 UTC 2009


Move notify flag settings from rpmInstall and rpmErase to rpmSetNotifyFlag.

As you can see
-rpmVSFlags rpmSetVSFlags(struct rpmInstallArguments_s * ia)
+static rpmVSFlags rpmSetVSFlags(struct rpmInstallArguments_s * ia)

and
+static void rpmSetNotifyFlag(struct rpmInstallArguments_s * ia,
+		      rpmts ts)

I have kept both previous patch common function and this one static.
Upto this patch rpmErase has become clean and very simple to
understand. rpmInstall is still a big dragon. :(

Comments and suggestions ? Suggestions on Naming of functions are also welcome ?
-- 
rakesh


diff --git a/lib/rpminstall.c b/lib/rpminstall.c
index 7e72458..0b37349 100644
--- a/lib/rpminstall.c
+++ b/lib/rpminstall.c
@@ -71,7 +71,7 @@ static void printHash(const rpm_loff_t amount, const
rpm_loff_t total)
     }
 }

-rpmVSFlags rpmSetVSFlags(struct rpmInstallArguments_s * ia)
+static rpmVSFlags rpmSetVSFlags(struct rpmInstallArguments_s * ia)
 {
     rpmVSFlags vsflags;

@@ -204,6 +204,16 @@ void * rpmShowProgress(const void * arg,
     return rc;
 }	

+static void rpmSetNotifyFlag(struct rpmInstallArguments_s * ia,
+		      rpmts ts)
+{
+    int notifyFlags, xx;
+
+    notifyFlags = ia->cliInterfaceFlags | (rpmIsVerbose() ? RPMCLI_LABEL : 0 );
+    xx = rpmtsSetNotifyCallback(ts,
+				rpmShowProgress, (void *) ((long)notifyFlags));
+}
+
 struct rpmEIU {
     Header h;
     FD_t fd;
@@ -246,11 +256,7 @@ int rpmInstall(rpmts ts, struct
rpmInstallArguments_s * ia, ARGV_t fileArgv)
     vsflags = rpmSetVSFlags(ia);
     ovsflags = rpmtsSetVSFlags(ts, (vsflags | RPMVSF_NEEDPAYLOAD));

-    {	int notifyFlags;
-	notifyFlags = ia->cliInterfaceFlags | (rpmIsVerbose() ? RPMCLI_LABEL : 0 );
-	xx = rpmtsSetNotifyCallback(ts,
-			rpmShowProgress, (void *) ((long)notifyFlags));
-    }
+    rpmSetNotifyFlag(ia, ts);

     if ((eiu->relocations = relocations) != NULL) {
 	while (eiu->relocations->oldPath)
@@ -580,11 +586,7 @@ int rpmErase(rpmts ts, struct
rpmInstallArguments_s * ia, ARGV_const_t argv)
     (void) rpmtsSetFlags(ts, ia->transFlags);

 #ifdef	NOTYET	/* XXX no callbacks on erase yet */
-    {	int notifyFlags, xx;
-	notifyFlags = ia->cliInterfaceFlags | (rpmIsVerbose() ? RPMCLI_LABEL : 0 );
-	xx = rpmtsSetNotifyCallback(ts,
-			rpmShowProgress, (void *) ((long)notifyFlags));
-    }
+    rpmSetNotifyFlag(ia, ts);
 #endif

     qfmt = rpmExpand("%{?_query_all_fmt}\n", NULL);
-- 
1.6.0.6


More information about the Rpm-maint mailing list