combined the two custom-action functions

git-svn-id: 9f3514be25e8c4f808c923faecc75db62e18396e@1540 ce7afbd9-0f25-0410-bca2-9054d3de1fdb

--- modules/xml/src/module-xml.c
+++ modules/xml/src/module-xml.c
@@ -111,9 +111,7 @@

 struct mexecinfo **einit_module_xml_mxdata = NULL;
 struct lmodule **einit_module_xml_shutdown = NULL;
-
 struct dexecinfo **einit_mod_daemon_dxdata = NULL;
-struct lmodule **einit_mod_daemon_shutdown = NULL;

 void einit_module_xml_ipc_event_handler (struct einit_event *ev) {
  if (ev && ev->argv && ev->argv[0] && ev->argv[1] && strmatch(ev->argv[0], "examine") && strmatch(ev->argv[1], "configuration")) {
@@ -142,14 +140,6 @@

    for (; einit_module_xml_shutdown[i]; i++) {
     mod(einit_module_custom, einit_module_xml_shutdown[i], "on-shutdown");
-   }
-  }
-
-  if (einit_mod_daemon_shutdown) {
-   uint32_t i = 0;
-
-   for (; einit_mod_daemon_shutdown[i]; i++) {
-    mod(einit_module_custom, einit_mod_daemon_shutdown[i], "on-shutdown");
    }
   }
  }
@@ -443,8 +433,8 @@
     lm = mod_update (lm);
     doop = 0;

-    if (shutdownaction && !inset ((const void **)einit_mod_daemon_shutdown, (void *)lm, SET_NOALLOC)) {
-     einit_mod_daemon_shutdown = (struct lmodule **)setadd ((void **)einit_mod_daemon_shutdown, (void *)lm, SET_NOALLOC);
+    if (shutdownaction && !inset ((const void **)einit_module_xml_shutdown, (void *)lm, SET_NOALLOC)) {
+     einit_module_xml_shutdown = (struct lmodule **)setadd ((void **)einit_module_xml_shutdown, (void *)lm, SET_NOALLOC);
     }
     break;
    }
@@ -460,34 +450,14 @@
     new->custom = (int (*)(void *, char *, struct einit_event *))einit_module_xml_daemon_custom;
     new->cleanup = einit_module_xml_daemon_cleanup_after_module;

-    if (shutdownaction && !inset ((const void **)einit_mod_daemon_shutdown, (void *)new, SET_NOALLOC)) {
-     einit_mod_daemon_shutdown = (struct lmodule **)setadd ((void **)einit_mod_daemon_shutdown, (void *)new, SET_NOALLOC);
+    if (shutdownaction && !inset ((const void **)einit_module_xml_shutdown, (void *)new, SET_NOALLOC)) {
+     einit_module_xml_shutdown = (struct lmodule **)setadd ((void **)einit_module_xml_shutdown, (void *)new, SET_NOALLOC);
     }
    }
   }
  }

  return 0;
-}
-
-int einit_module_xml_pexec_wrapper_custom (struct mexecinfo *shellcmd, char *command, struct einit_event *status) {
- if (strmatch (command, "zap"))
-  return status_ok | status_disabled;
- else if (shellcmd->oattrs) {
-  char tmp[BUFFERSIZE];
-
-  esprintf (tmp, BUFFERSIZE, "execute:%s", command);
-
-  uint32_t i = 0;
-
-  for (; shellcmd->oattrs[i]; i+=2 ) {
-   if (strmatch (shellcmd->oattrs[i], tmp)) {
-    return status_enabled | pexec (shellcmd->oattrs[i+1], (const char **)shellcmd->variables, shellcmd->uid, shellcmd->gid, shellcmd->user, shellcmd->group, shellcmd->environment, status);
-   }
-  }
- }
-
- return status_failed | status_command_not_implemented;
 }

 int einit_module_xml_daemon_enable (struct dexecinfo *dexec, struct einit_event *status) {
@@ -498,25 +468,32 @@
  return stopdaemon (dexec, status);
 }

+int einit_module_xml_custom (char **arbattrs, char *command, struct einit_event *status, char **variables, uid_t uid, gid_t gid, char *user, char *group, char **environment) {
+ if (arbattrs) {
+  char tmp[BUFFERSIZE];
+
+  esprintf (tmp, BUFFERSIZE, "execute:%s", command);
+
+  uint32_t i = 0;
+
+  for (; arbattrs[i]; i+=2 ) {
+   if (strmatch (arbattrs[i], tmp)) {
+    return status_enabled | pexec (arbattrs[i+1], (const char **)variables, uid, gid, user, group, environment, status);
+   }
+  }
+ }
+
+ return status_failed | status_command_not_implemented | status_enabled;
+}
+
 int einit_module_xml_daemon_custom (struct dexecinfo *dexec, char *command, struct einit_event *status) {
- if (strmatch (command, "zap"))
-  return status_ok | status_disabled;
- else if (dexec->oattrs) {
-  char tmp[BUFFERSIZE];
-
-  esprintf (tmp, BUFFERSIZE, "execute:%s", command);
-
-  uint32_t i = 0;
-
-  for (; dexec->oattrs[i]; i+=2 ) {
-   if (strmatch (dexec->oattrs[i], tmp)) {
-    return status_enabled | pexec (dexec->oattrs[i+1], (const char **)dexec->variables, dexec->uid, dexec->gid, dexec->user, dexec->group, dexec->environment, status);
-   }
-  }
- }
-
- return status_failed | status_command_not_implemented;
-}
+ return einit_module_xml_custom (dexec->oattrs, command, status, dexec->variables, dexec->uid, dexec->gid, dexec->user, dexec->group, dexec->environment);
+}
+
+int einit_module_xml_pexec_wrapper_custom (struct mexecinfo *shellcmd, char *command, struct einit_event *status) {
+ return einit_module_xml_custom (shellcmd->oattrs, command, status, shellcmd->variables, shellcmd->uid, shellcmd->gid, shellcmd->user, shellcmd->group, shellcmd->environment);
+}
+

 int einit_module_xml_pexec_wrapper (struct mexecinfo *shellcmd, struct einit_event *status) {
  int retval = status_failed;


Removed using namespace std; decklaration since that's dangerous in a header, and added std:: specifiers to iostream functions.

--- src/vw/InterestPoint/ImageOctave.h
+++ src/vw/InterestPoint/ImageOctave.h
@@ -11,7 +11,6 @@
 // STL
 #include <vector>
 #include <iostream>
-using namespace std;

 // A magic number, this value used by Lowe.  Learn this parameter?
 #define INITIAL_SIGMA (1.6)
@@ -37,8 +36,8 @@
   int num_planes;        // Number of planes (P+2) for ratio of 2^(1/P)
   float init_sigma;      // Initial sigma to apply to base level image
   float sigma_ratio;     // Ratio of sigmas between levels:
-  vector<float> sigma;   // sigmas corresponding to scales
-  vector< ImageView<PixelT> > scales; // Scaled images in the octave
+  std::vector<float> sigma;   // sigmas corresponding to scales
+  std::vector< ImageView<PixelT> > scales; // Scaled images in the octave

   // This constructor is intended for building the first octave from a
   // source image.
@@ -102,7 +101,8 @@

     // Blur images.  Assume some sigma for the first one.
     vw::vw_out(DebugMessage) << "assuming camera_sigma " << CAMERA_SIGMA
-			     << ", can we devise a way to find it?" << endl;
+			     << ", can we devise a way to find it?"
+			     << std::endl;
     float camera_sigma = CAMERA_SIGMA;

     // Sigma to use for blurring step to achieve a final sigma in each
@@ -113,7 +113,8 @@
     if (sigma[0]>camera_sigma){
       use_sigma = sqrt( sigma[0]*sigma[0] - camera_sigma*camera_sigma );
       vw::vw_out(DebugMessage) << "making plane " << 0 << " using sigma "
-	        << use_sigma << " so final sigma is " << sigma[0] << endl;
+			       << use_sigma << " so final sigma is "
+			       << sigma[0] << std::endl;
       scales[0] = vw::gaussian_filter(scales[0], use_sigma);
     }

@@ -121,7 +122,8 @@
     for (int i=1; i<num_planes; i++){
       use_sigma = sqrt( sigma[i]*sigma[i] - sigma[i-1]*sigma[i-1] );
       vw::vw_out(DebugMessage) << "making plane " << i << " using sigma "
-		<< use_sigma << " so final sigma is " << sigma[i] << endl;
+			       << use_sigma << " so final sigma is "
+			       << sigma[i] << std::endl;
       scales[i] = vw::gaussian_filter(scales[i-1], use_sigma);
     }

@@ -161,7 +163,8 @@
     for (int k=2; k<num_planes; k++){
       use_sigma = sqrt( sigma[k]*sigma[k] - sigma[k-1]*sigma[k-1] );
       vw::vw_out(DebugMessage) << "making plane " << k << " using sigma "
-                << use_sigma << " so final sigma is " << sigma[k] << endl;
+			       << use_sigma << " so final sigma is "
+			       << sigma[k] << std::endl;
       scales[k] = vw::gaussian_filter(scales[k-1], use_sigma);
     }


Remove the boss mutex from worker_threads_optional_wait.c

--- src/worker_threads_optional_wait.c
+++ src/worker_threads_optional_wait.c
@@ -24,8 +24,6 @@
 	enum pt_state state;
 	pthread_cond_t work_cond;
 	pthread_mutex_t work_mtx;
-	pthread_cond_t boss_cond;
-	pthread_mutex_t boss_mtx;
 } pt_info;

 pthread_t threads[TASK_NB][2];
@@ -42,15 +40,8 @@

 	printf("<worker %i:%i> start\n", task, TYPE1);

-	// ensure boss is waiting
-	pthread_mutex_lock(&(info->boss_mtx));
-
 	// signal to boss that setup is complete
 	info->state = IDLE;
-
-	// wake-up signal
-	pthread_cond_signal(&(info->boss_cond));
-	pthread_mutex_unlock(&(info->boss_mtx));

 	while (1) {
 		pthread_cond_wait(&(info->work_cond), &(info->work_mtx));
@@ -72,15 +63,8 @@
 		usleep(size*1000000);
 		printf("<worker %i:%i> JOB end\n", task, TYPE1);

-		// ensure boss is waiting
-		pthread_mutex_lock(&(info->boss_mtx));
-
 		// indicate that job is done
 		info->state = IDLE;
-
-		// wake-up signal
-		pthread_cond_signal(&(info->boss_cond));
-		pthread_mutex_unlock(&(info->boss_mtx));
 	}

 	pthread_mutex_unlock(&(info->work_mtx));
@@ -98,15 +82,8 @@

 	printf("<worker %i:%i> start\n", task, TYPE2);

-	// ensure boss is waiting
-	pthread_mutex_lock(&(info->boss_mtx));
-
 	// signal to boss that setup is complete
 	info->state = IDLE;
-
-	// wake-up signal
-	pthread_cond_signal(&(info->boss_cond));
-	pthread_mutex_unlock(&(info->boss_mtx));

 	while (1) {
 		pthread_cond_wait(&(info->work_cond), &(info->work_mtx));
@@ -128,15 +105,8 @@
 		usleep(size*1000000);
 		printf("<worker %i:%i> JOB end\n", task, TYPE2);

-		// ensure boss is waiting
-		pthread_mutex_lock(&(info->boss_mtx));
-
 		// indicate that job is done
 		info->state = IDLE;
-
-		// wake-up signal
-		pthread_cond_signal(&(info->boss_cond));
-		pthread_mutex_unlock(&(info->boss_mtx));
 	}

 	pthread_mutex_unlock(&(info->work_mtx));
@@ -164,12 +134,17 @@
 	pt_info *info = &(shared_info[task][type]);

 	while (1) {
-		pthread_cond_wait(&(info->boss_cond), &(info->boss_mtx));
+		// ensure worker is waiting
+		pthread_mutex_lock(&(info->work_mtx));

 		if (IDLE == info->state) {
 			break;
 		}
-	}
+
+		pthread_mutex_unlock(&(info->work_mtx));
+	}
+
+	pthread_mutex_unlock(&(info->work_mtx));
 }

 void app_init()
@@ -186,10 +161,6 @@

 		pthread_cond_init(&(info->work_cond), NULL);
 		pthread_mutex_init(&(info->work_mtx), NULL);
-		pthread_cond_init(&(info->boss_cond), NULL);
-		pthread_mutex_init(&(info->boss_mtx), NULL);
-
-		pthread_mutex_lock(&(info->boss_mtx));

 		pthread_create(&threads[i][TYPE1], NULL, task_type1,
 			       (void *)info);
@@ -206,10 +177,6 @@

 		pthread_cond_init(&(info->work_cond), NULL);
 		pthread_mutex_init(&(info->work_mtx), NULL);
-		pthread_cond_init(&(info->boss_cond), NULL);
-		pthread_mutex_init(&(info->boss_mtx), NULL);
-
-		pthread_mutex_lock(&(info->boss_mtx));

 		pthread_create(&threads[i][TYPE2], NULL, task_type2,
 			       (void *)info);
@@ -243,11 +210,6 @@

 			pthread_mutex_destroy(&(info->work_mtx));
 			pthread_cond_destroy(&(info->work_cond));
-
-			pthread_mutex_unlock(&(info->boss_mtx));
-			pthread_mutex_destroy(&(info->boss_mtx));
-			pthread_cond_destroy(&(info->boss_cond));
-
 		}
 	}
 }


Remove  more debug, increase population size, all works

--- azpcs/1.c
+++ azpcs/1.c
@@ -6,8 +6,8 @@
 #define N 3 //5
 #define N2 (N * N)
 #define MIN_BOUND 72 //3800
-#define POPSZ 5 //100
-#define FAMSZ 3
+#define POPSZ 100
+#define FAMSZ 5
 #define MAX_EPOCH 1000

 #define OO 99999999999L
@@ -247,17 +247,6 @@
 		combine(i, family[best1_ix], family[best2_ix]);
 	}
 	epoch++;
-
-	// debug print
-	for (int i = 0; i < POPSZ; i++) {
-		printf("Pop %d: ", i);
-		for (int j = 0; j < N2; j++)
-			if (epoch % 2 == 0)
-				printf("%d ", pop1[i][j]);
-			else
-				printf("%d ", pop2[i][j]);
-		printf("\n");
-	}
 }

 int main()


Render dummy history items as separators

Until we find a better way this should reduce confusion about
'empty' folders appearing.

--- panels/midori-history.c
+++ panels/midori-history.c
@@ -256,9 +256,10 @@

             gtk_tree_store_insert_with_values (model, &root_iter, NULL,
                                                0, 0, item, 1, sdate, -1);
-            /* FIXME: Always show expanders even if no child nodes? */
+            /* That's an invisible dummy, so we always have an expander */
+            /* FIXME: Hide this row */
             gtk_tree_store_insert_with_values (model, &iter, &root_iter,
-                0, 0, item, 1, katze_item_get_name (item), -1);
+                0, 0, NULL, 1, NULL, -1);

             if (age > 1 && age < 7)
                 g_free (sdate);
@@ -354,11 +355,12 @@

         gtk_tree_model_get (model, &iter, 0, &item, -1);

-        is_page = !KATZE_IS_ARRAY (item) && katze_item_get_uri (item);
+        is_page = item && katze_item_get_uri (item);
         gtk_widget_set_sensitive (history->bookmark, is_page);
         gtk_widget_set_sensitive (history->delete, TRUE);

-        g_object_unref (item);
+        if (item)
+            g_object_unref (item);
     }
     else
     {
@@ -503,11 +505,13 @@
                                         GtkWidget*         treeview)
 {
     KatzeItem* item;
-    GdkPixbuf* pixbuf = NULL;
+    GdkPixbuf* pixbuf;

     gtk_tree_model_get (model, iter, 0, &item, -1);

-    if (katze_item_get_uri (item))
+    if (!item)
+        pixbuf = NULL;
+    else if (katze_item_get_uri (item))
         pixbuf = katze_load_cached_icon (katze_item_get_uri (item), treeview);
     else
         pixbuf = gtk_widget_render_icon (treeview, GTK_STOCK_DIRECTORY,
@@ -516,9 +520,10 @@
     g_object_set (renderer, "pixbuf", pixbuf, NULL);

     if (pixbuf)
+    {
         g_object_unref (pixbuf);
-
-    g_object_unref (item);
+        g_object_unref (item);
+    }
 }

 #if HAVE_SQLITE
@@ -538,6 +543,10 @@
     if (gtk_tree_model_get_iter (model, &iter, path))
     {
         gtk_tree_model_get (model, &iter, 0, &item, -1);
+
+        if (!item)
+            return;
+
         uri = katze_item_get_uri (item);
         if (uri && *uri)
         {
@@ -731,6 +740,9 @@

         gtk_tree_model_get (model, &iter, 0, &item, -1);

+        if (!item)
+            return FALSE;
+
         if (event->button == 2)
         {
             const gchar* uri = katze_item_get_uri (item);
@@ -828,6 +840,22 @@
 }
 #endif

+static gboolean
+midori_history_row_sep_func (GtkTreeModel*  model,
+                             GtkTreeIter*   iter,
+                             MidoriHistory* history)
+{
+    KatzeItem* item;
+
+    gtk_tree_model_get (model, iter, 0, &item, -1);
+
+    if (item == NULL)
+        return TRUE;
+
+    g_object_unref (item);
+    return FALSE;
+}
+
 static void
 midori_history_init (MidoriHistory* history)
 {
@@ -844,6 +872,8 @@
     model = gtk_tree_store_new (2, KATZE_TYPE_ITEM, G_TYPE_STRING);
     treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
+    gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (treeview),
+        (GtkTreeViewRowSeparatorFunc)midori_history_row_sep_func, history, NULL);
     column = gtk_tree_view_column_new ();
     renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
     gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);


Bluetooth: Update L2CAP version information

We did some changes on the L2CAP configuration process and its behaviour
is bit different now. That justifies a updated on the L2CAP version.

Signed-off-by: Gustavo F. Padovan <8463bae6aa74c6c37654a5ac7ce3bbb9fe6ffff8@profusion.mobi>
Signed-off-by: Marcel Holtmann <44592b4eea36663c86b994bb0ea99d15309c1c7d@holtmann.org>

--- net/bluetooth/l2cap.c
+++ net/bluetooth/l2cap.c
@@ -54,7 +54,7 @@
 #include <net/bluetooth/hci_core.h>
 #include <net/bluetooth/l2cap.h>

-#define VERSION "2.14"
+#define VERSION "2.15"

 static int enable_ertm = 0;


tipc: ensure all name sequences are released when name table is stopped

As TIPC subscriber server is terminated before name table, no user
depends on subscription list of name sequence when name table is
stopped. Therefore, all name sequences stored in name table should
be released whatever their subscriptions lists are empty or not,
otherwise, memory leak might happen.

Signed-off-by: Ying Xue <c1cbb87de349443b90fa63f6d2cc5403843bc133@windriver.com>
Reviewed-by: Erik Hugne <527d9b95423f3946c01de0ba884fdd8bb4a3759d@ericsson.com>
Reviewed-by: Jon Maloy <0e60c7c02f6d30eccc82572d2a89766b1b2a3d45@ericsson.com>
Tested-by: Erik Hugne <527d9b95423f3946c01de0ba884fdd8bb4a3759d@ericsson.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


Sync with usrsctp.

Sync with usrsctp.

--- netinet/sctp_header.h
+++ netinet/sctp_header.h
@@ -603,7 +603,7 @@
 #include <packoff.h>
 #endif
 #if defined(__Userspace_os_Windows)
-#pragma pack ()
+#pragma pack(pop)
 #endif
 #undef SCTP_PACKED
 #endif				/* !__sctp_header_h__ */


Improve compilability.

Improve compilability.

--- netinet/sctp_sysctl.c
+++ netinet/sctp_sysctl.c
@@ -246,8 +246,15 @@
 {
 	struct sctp_ifn *sctp_ifn;
 	struct sctp_ifa *sctp_ifa;
-	int loopback_scope, ipv4_local_scope, local_scope, site_scope;
-	int ipv4_addr_legal, ipv6_addr_legal;
+	int loopback_scope;
+#ifdef INET
+	int ipv4_local_scope;
+	int ipv4_addr_legal;
+#endif
+#ifdef INET6
+	int local_scope, site_scope;
+	int ipv6_addr_legal;
+#endif
 #if defined(__Userspace__)
 	int conn_addr_legal;
 #endif
@@ -257,68 +264,90 @@
 	int error;

 	/* Turn on all the appropriate scope */
-	if (stcb) {
+	if (stcb != NULL) {
 		/* use association specific values */
 		loopback_scope = stcb->asoc.scope.loopback_scope;
+#ifdef INET
 		ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope;
+		ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
+#endif
+#ifdef INET6
 		local_scope = stcb->asoc.scope.local_scope;
 		site_scope = stcb->asoc.scope.site_scope;
-		ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
 		ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal;
+#endif
 #if defined(__Userspace__)
 		conn_addr_legal = stcb->asoc.scope.conn_addr_legal;
 #endif
 	} else {
 		/* Use generic values for endpoints. */
 		loopback_scope = 1;
+#ifdef INET
 		ipv4_local_scope = 1;
+#endif
+#ifdef INET6
 		local_scope = 1;
 		site_scope = 1;
+#endif
 		if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
+#ifdef INET6
 			ipv6_addr_legal = 1;
+#endif
+#ifdef INET
 			if (SCTP_IPV6_V6ONLY(inp)) {
 				ipv4_addr_legal = 0;
 			} else {
 				ipv4_addr_legal = 1;
 			}
+#endif
 #if defined(__Userspace__)
 			conn_addr_legal = 0;
 #endif
 		} else {
+#ifdef INET6
 			ipv6_addr_legal = 0;
+#endif
 #if defined(__Userspace__)
 			if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_CONN) {
 				conn_addr_legal = 1;
+#ifdef INET
 				ipv4_addr_legal = 0;
+#endif
 			} else {
 				conn_addr_legal = 0;
+#ifdef INET
 				ipv4_addr_legal = 1;
+#endif
 			}
 #else
+#ifdef INET
 			ipv4_addr_legal = 1;
 #endif
-		}
-	}
-
-	/* neither Mac OS X nor FreeBSD support multiple routing functions */
+#endif
+		}
+	}
+
+	/* Neither Mac OS X nor FreeBSD support multiple routing functions. */
 	if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
 		SCTP_INP_RUNLOCK(inp);
 		SCTP_INP_INFO_RUNLOCK();
-		return (-1);
+		return (ENOENT);
 	}
 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
 		LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
-			if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn))
-				/* Skip loopback if loopback_scope not set */
+			if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) {
+				/* Skip loopback if loopback_scope not set. */
 				continue;
+			}
 			LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
-				if (stcb) {
+				if (stcb != NULL) {
 					/*
-					 * ignore if blacklisted at
-					 * association level
+					 * Ignore if blacklisted at
+					 * association level.
 					 */
-					if (sctp_is_addr_restricted(stcb, sctp_ifa))
+					if (sctp_is_addr_restricted(stcb, sctp_ifa)) {
 						continue;
+					}
 				}
 				switch (sctp_ifa->address.sa.sa_family) {
 #ifdef INET
@@ -327,16 +356,18 @@
 						struct sockaddr_in *sin;

 						sin = &sctp_ifa->address.sin;
-						if (sin->sin_addr.s_addr == 0)
+						if (sin->sin_addr.s_addr == 0) {
 							continue;
+						}
 #if defined(__FreeBSD__) && !defined(__Userspace__)
 						if (prison_check_ip4(inp->ip_inp.inp.inp_cred,
 						                     &sin->sin_addr) != 0) {
 							continue;
 						}
 #endif
-						if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)))
+						if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))) {
 							continue;
+						}
 					} else {
 						continue;
 					}
@@ -348,8 +379,9 @@
 						struct sockaddr_in6 *sin6;

 						sin6 = &sctp_ifa->address.sin6;
-						if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
+						if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
 							continue;
+						}
 #if defined(__FreeBSD__) && !defined(__Userspace__)
 						if (prison_check_ip6(inp->ip_inp.inp.inp_cred,
 						                     &sin6->sin6_addr) != 0) {
@@ -357,11 +389,13 @@
 						}
 #endif
 						if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
-							if (local_scope == 0)
+							if (local_scope == 0) {
 								continue;
+							}
 						}
-						if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)))
+						if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) {
 							continue;
+						}
 					} else {
 						continue;
 					}
@@ -382,7 +416,7 @@
 				SCTP_INP_RUNLOCK(inp);
 				SCTP_INP_INFO_RUNLOCK();
 				error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
-				if (error) {
+				if (error != 0) {
 					return (error);
 				} else {
 					SCTP_INP_INFO_RLOCK();
@@ -393,7 +427,7 @@
 	} else {
 		LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
 			/* ignore if blacklisted at association level */
-			if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa))
+			if (stcb != NULL && sctp_is_addr_restricted(stcb, laddr->ifa))
 				continue;
 			memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
 			memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore));
@@ -402,7 +436,7 @@
 			SCTP_INP_RUNLOCK(inp);
 			SCTP_INP_INFO_RUNLOCK();
 			error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
-			if (error) {
+			if (error != 0) {
 				return (error);
 			} else {
 				SCTP_INP_INFO_RLOCK();
@@ -416,7 +450,7 @@
 	SCTP_INP_INFO_RUNLOCK();
 	error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));

-	if (error) {
+	if (error != 0) {
 		return (error);
 	} else {
 		SCTP_INP_INFO_RLOCK();


use stdarg when compiling with ANSI C compiler

--- lang/cem/cemcom.ansi/error.c
+++ lang/cem/cemcom.ansi/error.c
@@ -6,7 +6,11 @@
 /*	E R R O R   A N D  D I A G N O S T I C   R O U T I N E S	*/

 #include	"lint.h"
+#if __STDC__
+#include	<stdarg.h>
+#else
 #include	<varargs.h>
+#endif
 #include	<system.h>
 #ifndef	LINT
 #include	<em.h>
@@ -60,32 +64,29 @@

 static _error();

-/*VARARGS*/
-error(va_alist)				/* fmt, args */
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		_error(ERROR, dot.tk_file, dot.tk_line, ap);
-	}
-	va_end(ap);
-}
-
-/*VARARGS*/
-expr_error(va_alist)			/* expr, fmt, args */
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		register struct expr *expr = va_arg(ap, struct expr *);
-
+#if __STDC__
+/*VARARGS*/
+error(char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
+		_error(ERROR, dot.tk_file, dot.tk_line, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+expr_error(struct expr *expr, char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
 		if (!(expr->ex_flags & EX_ERROR)) {
 			/* to prevent proliferation */
-			_error(ERROR, expr->ex_file, expr->ex_line, ap);
+			_error(ERROR, expr->ex_file, expr->ex_line, fmt, ap);
 			expr->ex_flags |= EX_ERROR;
 		}
 	}
@@ -93,44 +94,39 @@
 }

 /*VARARGS*/
-lexstrict(va_alist)
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		_error(STRICT, FileName, LineNumber, ap);
-	}
-	va_end(ap);
-}
-
-/*VARARGS*/
-strict(va_alist)
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		_error(STRICT, dot.tk_file, dot.tk_line, ap);
-	}
-	va_end(ap);
-}
-
-/*VARARGS*/
-expr_strict(va_alist)			/* expr, fmt, args */
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		struct expr *expr = va_arg(ap, struct expr *);
-
+lexstrict(char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
+		_error(STRICT, FileName, LineNumber, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+strict(char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
+		_error(STRICT, dot.tk_file, dot.tk_line, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+expr_strict(struct expr *expr, char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
 		if (!(expr->ex_flags & EX_ERROR)) {
 			/* to prevent proliferation */
-			_error(STRICT, expr->ex_file, expr->ex_line, ap);
+			_error(STRICT, expr->ex_file, expr->ex_line, fmt, ap);
 		}
 	}
 	va_end(ap);
@@ -138,49 +134,40 @@

 #ifdef DEBUG
 /*VARARGS*/
-debug(va_alist)
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		_error(DO_DEBUG, dot.tk_file, dot.tk_line, ap);
-		/* _error(DO_DEBUG, NILEXPR, ap);
-		*/
+debug(char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
+		_error(DO_DEBUG, dot.tk_file, dot.tk_line, fmt, ap);
 	}
 	va_end(ap);
 }
 #endif /* DEBUG */

 /*VARARGS*/
-warning(va_alist)
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		_error(WARNING, dot.tk_file, dot.tk_line, ap);
-		/* _error(WARNING, NILEXPR, ap);
-		*/
-	}
-	va_end(ap);
-}
-
-/*VARARGS*/
-expr_warning(va_alist)			/* expr, fmt, args */
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		struct expr *expr = va_arg(ap, struct expr *);
-
+warning(char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
+		_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+expr_warning(struct expr *expr, char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
 		if (!(expr->ex_flags & EX_ERROR)) {
 			/* to prevent proliferation */
-			_error(WARNING, expr->ex_file, expr->ex_line, ap);
+			_error(WARNING, expr->ex_file, expr->ex_line, fmt, ap);
 		}
 	}
 	va_end(ap);
@@ -189,45 +176,40 @@
 #ifdef	LINT

 /*VARARGS*/
-def_warning(va_alist)			/* def, fmt, args */
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		register struct def *def = va_arg(ap, struct def *);
-
-		_error(WARNING, def->df_file, def->df_line, ap);
-	}
-	va_end(ap);
-}
-
-
-/*VARARGS*/
-hwarning(va_alist)			/* fmt, args */
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
+def_warning(struct def *def, char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
+		_error(WARNING, def->df_file, def->df_line, fmt, ap);
+	}
+	va_end(ap);
+}
+
+
+/*VARARGS*/
+hwarning(char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
 	{
 		if (loptions['h'])
-			_error(WARNING, dot.tk_file, dot.tk_line, ap);
-	}
-	va_end(ap);
-}
-
-/*VARARGS*/
-awarning(va_alist)			/* fmt, args */
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
+			_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+awarning(char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
 	{
 		if (loptions['a'])
-			_error(WARNING, dot.tk_file, dot.tk_line, ap);
+			_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
 	}
 	va_end(ap);
 }
@@ -235,40 +217,37 @@
 #endif	/* LINT */

 /*VARARGS*/
-lexerror(va_alist)			/* fmt, args */
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		_error(ERROR, FileName, LineNumber, ap);
-	}
-	va_end(ap);
-}
-
-/*VARARGS*/
-lexwarning(va_alist)			/* fmt, args */
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		_error(WARNING, FileName, LineNumber, ap);
-	}
-	va_end(ap);
-}
-
-/*VARARGS*/
-crash(va_alist)				/* fmt, args */
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		_error(CRASH, FileName, LineNumber, ap);
+lexerror(char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
+		_error(ERROR, FileName, LineNumber, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+lexwarning(char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
+		_error(WARNING, FileName, LineNumber, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+crash(char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
+		_error(CRASH, FileName, LineNumber, fmt, ap);
 	}
 	va_end(ap);

@@ -282,14 +261,13 @@
 }

 /*VARARGS*/
-fatal(va_alist)				/* fmt, args */
-	va_dcl
-{
-	va_list ap;
-
-	va_start(ap);
-	{
-		_error(FATAL, FileName, LineNumber, ap);
+fatal(char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	{
+		_error(FATAL, FileName, LineNumber, fmt, ap);
 	}
 	va_end(ap);

@@ -297,16 +275,266 @@
 	sys_stop(S_EXIT);
 	/*NOTREACHED*/
 }
+#else
+/*VARARGS*/
+error(va_alist)				/* fmt, args */
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		char *fmt = va_arg(ap, char *);
+		_error(ERROR, dot.tk_file, dot.tk_line, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+expr_error(va_alist)			/* expr, fmt, args */
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		register struct expr *expr = va_arg(ap, struct expr *);
+		char *fmt = va_arg(ap, char *);
+
+		if (!(expr->ex_flags & EX_ERROR)) {
+			/* to prevent proliferation */
+			_error(ERROR, expr->ex_file, expr->ex_line, fmt, ap);
+			expr->ex_flags |= EX_ERROR;
+		}
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+lexstrict(va_alist)
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		char *fmt = va_arg(ap, char *);
+		_error(STRICT, FileName, LineNumber, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+strict(va_alist)
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		char *fmt = va_arg(ap, char *);
+		_error(STRICT, dot.tk_file, dot.tk_line, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+expr_strict(va_alist)			/* expr, fmt, args */
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		struct expr *expr = va_arg(ap, struct expr *);
+		char *fmt = va_arg(ap, char *);
+
+		if (!(expr->ex_flags & EX_ERROR)) {
+			/* to prevent proliferation */
+			_error(STRICT, expr->ex_file, expr->ex_line, fmt, ap);
+		}
+	}
+	va_end(ap);
+}
+
+#ifdef DEBUG
+/*VARARGS*/
+debug(va_alist)
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		char *fmt = va_arg(ap, char *);
+		_error(DO_DEBUG, dot.tk_file, dot.tk_line, fmt, ap);
+	}
+	va_end(ap);
+}
+#endif /* DEBUG */
+
+/*VARARGS*/
+warning(va_alist)
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		char *fmt = va_arg(ap, char *);
+		_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+expr_warning(va_alist)			/* expr, fmt, args */
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		struct expr *expr = va_arg(ap, struct expr *);
+		char *fmt = va_arg(ap, char *);
+
+		if (!(expr->ex_flags & EX_ERROR)) {
+			/* to prevent proliferation */
+			_error(WARNING, expr->ex_file, expr->ex_line, fmt, ap);
+		}
+	}
+	va_end(ap);
+}
+
+#ifdef	LINT
+
+/*VARARGS*/
+def_warning(va_alist)			/* def, fmt, args */
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		register struct def *def = va_arg(ap, struct def *);
+		char *fmt = va_arg(ap, char *);
+
+		_error(WARNING, def->df_file, def->df_line, fmt, ap);
+	}
+	va_end(ap);
+}
+
+
+/*VARARGS*/
+hwarning(va_alist)			/* fmt, args */
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		char *fmt = va_arg(ap, char *);
+		if (loptions['h'])
+			_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+awarning(va_alist)			/* fmt, args */
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		char *fmt = va_arg(ap, char *);
+		if (loptions['a'])
+			_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
+	}
+	va_end(ap);
+}
+
+#endif	/* LINT */
+
+/*VARARGS*/
+lexerror(va_alist)			/* fmt, args */
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		char *fmt = va_arg(ap, char *);
+		_error(ERROR, FileName, LineNumber, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+lexwarning(va_alist)			/* fmt, args */
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		char *fmt = va_arg(ap, char *);
+		_error(WARNING, FileName, LineNumber, fmt, ap);
+	}
+	va_end(ap);
+}
+
+/*VARARGS*/
+crash(va_alist)				/* fmt, args */
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		char *fmt = va_arg(ap, char *);
+		_error(CRASH, FileName, LineNumber, fmt, ap);
+	}
+	va_end(ap);
+
+	C_close();
+#ifdef	DEBUG
+	sys_stop(S_ABORT);
+#else	/* DEBUG */
+	sys_stop(S_EXIT);
+#endif	/* DEBUG */
+	/* NOTREACHED */
+}
+
+/*VARARGS*/
+fatal(va_alist)				/* fmt, args */
+	va_dcl
+{
+	va_list ap;
+
+	va_start(ap);
+	{
+		char *fmt = va_arg(ap, char *);
+		_error(FATAL, FileName, LineNumber, fmt, ap);
+	}
+	va_end(ap);
+
+	if (C_busy()) C_close();
+	sys_stop(S_EXIT);
+	/*NOTREACHED*/
+}
+#endif

 static
-_error(class, fn, ln, ap)
+_error(class, fn, ln, fmt, ap)
 	int class;
 	char *fn;
 	unsigned int ln;
+	char *fmt;
 	va_list ap;
 {
 	char *remark;
-	char *fmt = va_arg(ap, char *);

 	/* check visibility of message */
 	switch (class)	{


fixing timing bug, need to clean up

fixing timing bug, need to clean up

--- networking/http_req.c
+++ networking/http_req.c
@@ -141,10 +141,11 @@
 	 *
 	 */
 	char bbuff[10000] = {0};
-	msg = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: keep-alive\r\n\r\n";
+	msg = "\r\n\r\nGET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n";
+
 	printf("Message:\n%s\n", msg);
-	sent = send(sockfd, msg, sizeof msg, 0);
-	printf("%d of %d bytes sent\n" , sent , sizeof msg);
+	sent = send(sockfd, msg, strlen(msg), 0);
+	printf("%d of %d bytes sent\n" , sent , strlen(msg));
 	recvd = recv(sockfd, bbuff, sizeof bbuff, 0);
 	if(recvd)
 		printf("%d of %d bytes recieved\n", recvd , sizeof bbuff);


touchpad_st: remove beacon count logs

touchpad_st: remove beacon count logs

Currently, beacon count is logged every second.  Suppress the log and
only print errors when beacon count is frozen.

BRANCH=nocturne
BUG=None
TEST=manual on whiskers
Signed-off-by: Wei-Han Chen <5413a119f383c3f4549c3ef659403f393bf06e9d@chromium.org>

Change-Id: I20eb992b5f006f425bb5a94bad8e0e5b3015a7ac
Reviewed-on: https://chromium-review.googlesource.com/1322187
Commit-Ready: Wei-Han Chen <5413a119f383c3f4549c3ef659403f393bf06e9d@chromium.org>
Tested-by: Wei-Han Chen <5413a119f383c3f4549c3ef659403f393bf06e9d@chromium.org>
Reviewed-by: Nicolas Boichat <f3daba1cdc403799935674d3cd4b0e5bd1804232@chromium.org>

--- driver/touchpad_st.c
+++ driver/touchpad_st.c
@@ -716,12 +716,15 @@
 	 * Resetting touchpad should be the correct action.
 	 */
 	if (e->report.report_type == ST_TP_STATUS_BEACON) {
+#if 0
 		const uint8_t touch_count = e->report.reserved;

 		CPRINTS("BEACON: idle count=%08x", info);
 		CPRINTS("  touch count=%d  touch slot=%04x",
 			touch_count, touch_slot);
+#endif
 		if (prev_idle_count == info && touch_slot == 0) {
+			CPRINTS("  idle count=%08x not changed", info);
 			tp_control |= TP_CONTROL_SHALL_RESET;
 			return;
 		}


ACPI: power.c: call acpi_get_name to get node name

acpi_ut_get_node_name is an internal acpica function.
use acpi_get_name to get node ascii name

Signed-off-by: Lin Ming <d6f051473f553588884d51874952f6fb19ae8261@intel.com>
Signed-off-by: Len Brown <b060cfa1096cc6e8be83699ddb4ed8a77dd63af5@intel.com>

--- drivers/acpi/power.c
+++ drivers/acpi/power.c
@@ -139,6 +139,8 @@
 {
 	acpi_status status = AE_OK;
 	unsigned long long sta = 0;
+	char node_name[5];
+	struct acpi_buffer buffer = { sizeof(node_name), node_name };

 	if (!handle || !state)
@@ -151,8 +153,10 @@
 	*state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON:
 			      ACPI_POWER_RESOURCE_STATE_OFF;

+	acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
+
 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
-			  acpi_ut_get_node_name(handle),
+			  node_name,
 				*state ? "on" : "off"));

 	return 0;


NVMe: Simplify completion handling

NVMe: Simplify completion handling

Instead of encoding the handler type in the bottom two bits of the
per-completion context pointer, store the handler function as well
as the context pointer.  This gives us more flexibility and the code
is clearer.  It comes at the cost of an extra 8k of memory per queue,
but this feels like a reasonable price to pay.

Signed-off-by: Matthew Wilcox <ed1245e46949b7b8f2bca25d41520ebc8aeefcf8@intel.com>

--- drivers/block/nvme.c
+++ drivers/block/nvme.c
@@ -135,8 +135,12 @@
 	BUILD_BUG_ON(sizeof(struct nvme_lba_range_type) != 64);
 }

+typedef void (*nvme_completion_fn)(struct nvme_queue *, void *,
+						struct nvme_completion *);
+
 struct nvme_cmd_info {
-	unsigned long ctx;
+	nvme_completion_fn fn;
+	void *ctx;
 	unsigned long timeout;
 };

@@ -149,7 +153,7 @@
  * alloc_cmdid() - Allocate a Command ID
  * @nvmeq: The queue that will be used for this command
  * @ctx: A pointer that will be passed to the handler
- * @handler: The ID of the handler to call
+ * @handler: The function to call on completion
  *
  * Allocate a Command ID for a queue.  The data passed in will
  * be passed to the completion handler.  This is implemented by using
@@ -160,14 +164,12 @@
  * May be called with local interrupts disabled and the q_lock held,
  * or with interrupts enabled and no locks held.
  */
-static int alloc_cmdid(struct nvme_queue *nvmeq, void *ctx, int handler,
-							unsigned timeout)
+static int alloc_cmdid(struct nvme_queue *nvmeq, void *ctx,
+				nvme_completion_fn handler, unsigned timeout)
 {
 	int depth = nvmeq->q_depth - 1;
 	struct nvme_cmd_info *info = nvme_cmd_info(nvmeq);
 	int cmdid;
-
-	BUG_ON((unsigned long)ctx & 3);

 	do {
 		cmdid = find_first_zero_bit(nvmeq->cmdid_data, depth);
@@ -175,13 +177,14 @@
 			return -EBUSY;
 	} while (test_and_set_bit(cmdid, nvmeq->cmdid_data));

-	info[cmdid].ctx = (unsigned long)ctx | handler;
+	info[cmdid].fn = handler;
+	info[cmdid].ctx = ctx;
 	info[cmdid].timeout = jiffies + timeout;
 	return cmdid;
 }

 static int alloc_cmdid_killable(struct nvme_queue *nvmeq, void *ctx,
-						int handler, unsigned timeout)
+				nvme_completion_fn handler, unsigned timeout)
 {
 	int cmdid;
 	wait_event_killable(nvmeq->sq_full,
@@ -189,47 +192,69 @@
 	return (cmdid < 0) ? -EINTR : cmdid;
 }

-/*
- * If you need more than four handlers, you'll need to change how
- * alloc_cmdid and nvme_process_cq work.  Consider using a special
- * CMD_CTX value instead, if that works for your situation.
- */
-enum {
-	sync_completion_id = 0,
-	bio_completion_id,
-};
-
-/* Special values must be a multiple of 4, and less than 0x1000 */
-#define CMD_CTX_BASE		(POISON_POINTER_DELTA + sync_completion_id)
+/* Special values must be less than 0x1000 */
+#define CMD_CTX_BASE		((void *)POISON_POINTER_DELTA)
 #define CMD_CTX_CANCELLED	(0x30C + CMD_CTX_BASE)
 #define CMD_CTX_COMPLETED	(0x310 + CMD_CTX_BASE)
 #define CMD_CTX_INVALID		(0x314 + CMD_CTX_BASE)
 #define CMD_CTX_FLUSH		(0x318 + CMD_CTX_BASE)

+static void special_completion(struct nvme_queue *nvmeq, void *ctx,
+						struct nvme_completion *cqe)
+{
+	if (ctx == CMD_CTX_CANCELLED)
+		return;
+	if (ctx == CMD_CTX_FLUSH)
+		return;
+	if (ctx == CMD_CTX_COMPLETED) {
+		dev_warn(nvmeq->q_dmadev,
+				"completed id %d twice on queue %d\n",
+				cqe->command_id, le16_to_cpup(&cqe->sq_id));
+		return;
+	}
+	if (ctx == CMD_CTX_INVALID) {
+		dev_warn(nvmeq->q_dmadev,
+				"invalid id %d completed on queue %d\n",
+				cqe->command_id, le16_to_cpup(&cqe->sq_id));
+		return;
+	}
+
+	dev_warn(nvmeq->q_dmadev, "Unknown special completion %p\n", ctx);
+}
+
 /*
  * Called with local interrupts disabled and the q_lock held.  May not sleep.
  */
-static unsigned long free_cmdid(struct nvme_queue *nvmeq, int cmdid)
-{
-	unsigned long data;
+static void *free_cmdid(struct nvme_queue *nvmeq, int cmdid,
+						nvme_completion_fn *fn)
+{
+	void *ctx;
 	struct nvme_cmd_info *info = nvme_cmd_info(nvmeq);

-	if (cmdid >= nvmeq->q_depth)
+	if (cmdid >= nvmeq->q_depth) {
+		*fn = special_completion;
 		return CMD_CTX_INVALID;
-	data = info[cmdid].ctx;
+	}
+	*fn = info[cmdid].fn;
+	ctx = info[cmdid].ctx;
+	info[cmdid].fn = special_completion;
 	info[cmdid].ctx = CMD_CTX_COMPLETED;
 	clear_bit(cmdid, nvmeq->cmdid_data);
 	wake_up(&nvmeq->sq_full);
-	return data;
-}
-
-static unsigned long cancel_cmdid(struct nvme_queue *nvmeq, int cmdid)
-{
-	unsigned long data;
+	return ctx;
+}
+
+static void *cancel_cmdid(struct nvme_queue *nvmeq, int cmdid,
+						nvme_completion_fn *fn)
+{
+	void *ctx;
 	struct nvme_cmd_info *info = nvme_cmd_info(nvmeq);
-	data = info[cmdid].ctx;
+	if (fn)
+		*fn = info[cmdid].fn;
+	ctx = info[cmdid].ctx;
+	info[cmdid].fn = special_completion;
 	info[cmdid].ctx = CMD_CTX_CANCELLED;
-	return data;
+	return ctx;
 }

 static struct nvme_queue *get_nvmeq(struct nvme_ns *ns)
@@ -485,7 +510,7 @@
 static int nvme_submit_flush_data(struct nvme_queue *nvmeq, struct nvme_ns *ns)
 {
 	int cmdid = alloc_cmdid(nvmeq, (void *)CMD_CTX_FLUSH,
-						sync_completion_id, IO_TIMEOUT);
+						special_completion, IO_TIMEOUT);
 	if (unlikely(cmdid < 0))
 		return cmdid;

@@ -518,7 +543,7 @@
 	nbio->bio = bio;

 	result = -EBUSY;
-	cmdid = alloc_cmdid(nvmeq, nbio, bio_completion_id, IO_TIMEOUT);
+	cmdid = alloc_cmdid(nvmeq, nbio, bio_completion, IO_TIMEOUT);
 	if (unlikely(cmdid < 0))
 		goto free_nbio;

@@ -599,45 +624,6 @@
 	return 0;
 }

-struct sync_cmd_info {
-	struct task_struct *task;
-	u32 result;
-	int status;
-};
-
-static void sync_completion(struct nvme_queue *nvmeq, void *ctx,
-						struct nvme_completion *cqe)
-{
-	struct sync_cmd_info *cmdinfo = ctx;
-	if (unlikely((unsigned long)cmdinfo == CMD_CTX_CANCELLED))
-		return;
-	if ((unsigned long)cmdinfo == CMD_CTX_FLUSH)
-		return;
-	if (unlikely((unsigned long)cmdinfo == CMD_CTX_COMPLETED)) {
-		dev_warn(nvmeq->q_dmadev,
-				"completed id %d twice on queue %d\n",
-				cqe->command_id, le16_to_cpup(&cqe->sq_id));
-		return;
-	}
-	if (unlikely((unsigned long)cmdinfo == CMD_CTX_INVALID)) {
-		dev_warn(nvmeq->q_dmadev,
-				"invalid id %d completed on queue %d\n",
-				cqe->command_id, le16_to_cpup(&cqe->sq_id));
-		return;
-	}
-	cmdinfo->result = le32_to_cpup(&cqe->result);
-	cmdinfo->status = le16_to_cpup(&cqe->status) >> 1;
-	wake_up_process(cmdinfo->task);
-}
-
-typedef void (*completion_fn)(struct nvme_queue *, void *,
-						struct nvme_completion *);
-
-static const completion_fn nvme_completions[4] = {
-	[sync_completion_id] = sync_completion,
-	[bio_completion_id]  = bio_completion,
-};
-
 static irqreturn_t nvme_process_cq(struct nvme_queue *nvmeq)
 {
 	u16 head, phase;
@@ -646,9 +632,8 @@
 	phase = nvmeq->cq_phase;

 	for (;;) {
-		unsigned long data;
-		void *ptr;
-		unsigned char handler;
+		void *ctx;
+		nvme_completion_fn fn;
 		struct nvme_completion cqe = nvmeq->cqes[head];
 		if ((le16_to_cpu(cqe.status) & 1) != phase)
 			break;
@@ -658,10 +643,8 @@
 			phase = !phase;
 		}

-		data = free_cmdid(nvmeq, cqe.command_id);
-		handler = data & 3;
-		ptr = (void *)(data & ~3UL);
-		nvme_completions[handler](nvmeq, ptr, &cqe);
+		ctx = free_cmdid(nvmeq, cqe.command_id, &fn);
+		fn(nvmeq, ctx, &cqe);
 	}

 	/* If the controller ignores the cq head doorbell and continuously
@@ -702,8 +685,23 @@
 static void nvme_abort_command(struct nvme_queue *nvmeq, int cmdid)
 {
 	spin_lock_irq(&nvmeq->q_lock);
-	cancel_cmdid(nvmeq, cmdid);
+	cancel_cmdid(nvmeq, cmdid, NULL);
 	spin_unlock_irq(&nvmeq->q_lock);
+}
+
+struct sync_cmd_info {
+	struct task_struct *task;
+	u32 result;
+	int status;
+};
+
+static void sync_completion(struct nvme_queue *nvmeq, void *ctx,
+						struct nvme_completion *cqe)
+{
+	struct sync_cmd_info *cmdinfo = ctx;
+	cmdinfo->result = le32_to_cpup(&cqe->result);
+	cmdinfo->status = le16_to_cpup(&cqe->status) >> 1;
+	wake_up_process(cmdinfo->task);
 }

 /*
@@ -719,7 +717,7 @@
 	cmdinfo.task = current;
 	cmdinfo.status = -EINTR;

-	cmdid = alloc_cmdid_killable(nvmeq, &cmdinfo, sync_completion_id,
+	cmdid = alloc_cmdid_killable(nvmeq, &cmdinfo, sync_completion,
 								timeout);
 	if (cmdid < 0)
 		return cmdid;
@@ -1201,18 +1199,15 @@
 	int cmdid;

 	for_each_set_bit(cmdid, nvmeq->cmdid_data, depth) {
-		unsigned long data;
-		void *ptr;
-		unsigned char handler;
+		void *ctx;
+		nvme_completion_fn fn;
 		static struct nvme_completion cqe = { .status = cpu_to_le16(NVME_SC_ABORT_REQ) << 1, };

 		if (!time_after(now, info[cmdid].timeout))
 			continue;
 		dev_warn(nvmeq->q_dmadev, "Timing out I/O %d\n", cmdid);
-		data = cancel_cmdid(nvmeq, cmdid);
-		handler = data & 3;
-		ptr = (void *)(data & ~3UL);
-		nvme_completions[handler](nvmeq, ptr, &cqe);
+		ctx = cancel_cmdid(nvmeq, cmdid, &fn);
+		fn(nvmeq, ctx, &cqe);
 	}
 }


clk: ti: Mark ti_clk_features static

clk: ti: Mark ti_clk_features static

This variable isn't exported outside of this file so mark it
static. Silences the following sparse warning:

drivers/clk/ti/clk.c:36:24: warning: symbol 'ti_clk_features' was not declared. Should it be static?

Acked-by: Tero Kristo <060a12f1fbc7e2e5d830b72f402ff04fdae8d312@ti.com>
Signed-off-by: Stephen Boyd <010521127f513270fe503d86ab8316ac5147f4b7@codeaurora.org>

--- drivers/clk/ti/clk.c
+++ drivers/clk/ti/clk.c
@@ -32,7 +32,7 @@
 struct ti_clk_ll_ops *ti_clk_ll_ops;
 static struct device_node *clocks_node_ptr[CLK_MAX_MEMMAPS];

-struct ti_clk_features ti_clk_features;
+static struct ti_clk_features ti_clk_features;

 struct clk_iomap {
 	struct regmap *regmap;


dma: of: make error message more meaningful by adding the node name

Signed-off-by: Lothar Waßmann <ba70e185ad5f8bd89713de0ae0734e59d08b9ad3@KARO-electronics.de>
Signed-off-by: Vinod Koul <5cf69c63beb17bf38d63aa0e923ee8256af0e205@intel.com>

--- drivers/dma/of-dma.c
+++ drivers/dma/of-dma.c
@@ -160,7 +160,8 @@

 	count = of_property_count_strings(np, "dma-names");
 	if (count < 0) {
-		pr_err("%s: dma-names property missing or empty\n", __func__);
+		pr_err("%s: dma-names property of node '%s' missing or empty\n",
+			__func__, np->full_name);
 		return NULL;
 	}


ide-cd: prepare cdrom_rw_intr() and cdrom_newpc_intr() to be merged

In cdrom_newpc_intr():
* cleanup variables in the 'transfer data' loop

In cdrom_rw_intr():
* rename 'sectors_to_transfer' to 'thislen'
* rename 'this_transfer' to 'blen'
* keep number of bytes (instead of sectors) in 'thislen' and 'blen'
* call 'xferfunc' only once for 'blen'
* cache 'rq->buffer' in 'ptr' variable
* check for 'rq->bio' before setting 'ptr' and 'blen'
* check for 'ptr' instead of 'rq->current_nr_sectors'

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <248de9df611a028e5eceb9d893a2ed6c24c89ef4@gmail.com>

--- drivers/ide/ide-cd.c
+++ drivers/ide/ide-cd.c
@@ -1123,8 +1123,8 @@
 	 * transfer data
 	 */
 	while (thislen > 0) {
-		int blen = blen = rq->data_len;
-		char *ptr = rq->data;
+		u8 *ptr = rq->data;
+		int blen = rq->data_len;

 		/*
 		 * bio backed?
@@ -1207,7 +1207,7 @@
 	struct cdrom_info *info = drive->driver_data;
 	struct request *rq = HWGROUP(drive)->rq;
 	xfer_func_t *xferfunc;
-	int stat, ireason, len, sectors_to_transfer, uptodate, nskip;
+	int stat, ireason, len, thislen, uptodate, nskip;
 	int dma_error = 0, dma = info->dma, write = rq_data_dir(rq) == WRITE;
 	u8 lowcyl = 0, highcyl = 0;

@@ -1262,7 +1262,7 @@
 		return ide_stopped;
 	}

-	sectors_to_transfer = len / SECTOR_SIZE;
+	thislen = len;

 	/* Check that the drive is expecting to do the same thing we are. */
 	if (write) {
@@ -1285,12 +1285,12 @@
 		 */
 		nskip = min_t(int, rq->current_nr_sectors
 				   - bio_cur_sectors(rq->bio),
-				   sectors_to_transfer);
+				   thislen >> 9);

 		if (nskip > 0) {
 			ide_cd_drain_data(drive, nskip);
 			rq->current_nr_sectors -= nskip;
-			sectors_to_transfer -= nskip;
+			thislen -= (nskip << 9);
 		}

 		xferfunc = HWIF(drive)->atapi_input_bytes;
@@ -1299,17 +1299,23 @@
 	/*
 	 * now loop and read/write the data
 	 */
-	while (sectors_to_transfer > 0) {
-		int this_transfer;
-
-		if (!rq->current_nr_sectors) {
+	while (thislen > 0) {
+		u8 *ptr = NULL;
+		int blen;
+
+		if (rq->bio) {
+			ptr = rq->buffer;
+			blen = rq->current_nr_sectors << 9;
+		}
+
+		if (!ptr) {
 			if (!write)
 				/*
 				 * If the buffers are full, cache the rest
 				 * of the data in our internal buffer.
 				 */
 				cdrom_buffer_sectors(drive, rq->sector,
-						     sectors_to_transfer);
+						     thislen >> 9);
 			else
 				printk(KERN_ERR "%s: %s: confused, missing "
 						"data\n",
@@ -1320,17 +1326,16 @@
 		/*
 		 * Figure out how many sectors we can transfer
 		 */
-		this_transfer = min_t(int, sectors_to_transfer, rq->current_nr_sectors);
-
-		while (this_transfer > 0) {
-			xferfunc(drive, rq->buffer, SECTOR_SIZE);
-			rq->buffer += SECTOR_SIZE;
-			--rq->nr_sectors;
-			--rq->current_nr_sectors;
-			++rq->sector;
-			--this_transfer;
-			--sectors_to_transfer;
-		}
+		if (blen > thislen)
+			blen = thislen;
+
+		xferfunc(drive, ptr, blen);
+
+		thislen -= blen;
+		rq->buffer += blen;
+		rq->nr_sectors -= (blen >> 9);
+		rq->current_nr_sectors -= (blen >> 9);
+		rq->sector += (blen >> 9);

 		/*
 		 * current buffer complete, move on


[C++] Doc.

[C++] Doc.

--- aeron-client/src/main/cpp/Context.h
+++ aeron-client/src/main/cpp/Context.h
@@ -39,10 +39,13 @@
 constexpr const std::int32_t NULL_VALUE = -1;

 /**
- * Function called by Aeron to deliver notification of an available image
+ * Function called by Aeron to deliver notification of an available image.
  *
  * The Image passed may not be the image used internally, but may be copied or moved freely.
  *
+ * Implementations should do the minimum work for passing off state to another thread for later processing
+ * and should not make a reentrant call back into the Aeron instance.
+ *
  * @param image that has become available.
  */
 typedef std::function<void(Image& image)> on_available_image_t;
@@ -52,12 +55,15 @@
  *
  * The Image passed is not guaranteed to be valid after the callback.
  *
+ * Implementations should do the minimum work for passing off state to another thread for later processing
+ * and should not make a reentrant call back into the Aeron instance.
+ *
  * @param image that has become unavailable
  */
 typedef std::function<void(Image& image)> on_unavailable_image_t;

 /**
- * Function called by Aeron to deliver notification that the media driver has added a Publication successfully
+ * Function called by Aeron to deliver notification that the media driver has added a Publication successfully.
  *
  * @param channel of the Publication
  * @param streamId within the channel of the Publication
@@ -71,7 +77,7 @@
     std::int64_t correlationId)> on_new_publication_t;

 /**
- * Function called by Aeron to deliver notification that the media driver has added a Subscription successfully
+ * Function called by Aeron to deliver notification that the media driver has added a Subscription successfully.
  *
  * @param channel of the Subscription
  * @param streamId within the channel of the Subscription
@@ -85,6 +91,9 @@
 /**
  * Function called by Aeron to deliver notification of a Counter being available.
  *
+ * Implementations should do the minimum work for passing off state to another thread for later processing
+ * and should not make a reentrant call back into the Aeron instance.
+ *
  * @param countersReader for more detail on the counter.
  * @param registrationId for the counter.
  * @param counterId      that is available.
@@ -98,6 +107,9 @@
 /**
  * Function called by Aeron to deliver notification of counter being removed.
  *
+ * Implementations should do the minimum work for passing off state to another thread for later processing
+ * and should not make a reentrant call back into the Aeron instance.
+ *
  * @param countersReader for more counter details.
  * @param registrationId for the counter.
  * @param counterId      that is unavailable.
@@ -113,6 +125,7 @@

 /**
  * The Default handler for Aeron runtime exceptions.
+ *
  * When a DriverTimeoutException is encountered, this handler will exit the program.
  *
  * The error handler can be overridden by supplying an {@link Context} with a custom handler.
@@ -187,7 +200,7 @@
     /// @endcond

     /**
-     * Set the directory that the Aeron client will use to communicate with the media driver
+     * Set the directory that the Aeron client will use to communicate with the media driver.
      *
      * @param directory to use
      * @return reference to this Context instance
@@ -199,7 +212,7 @@
     }

     /**
-     * Return the path to the CnC file used by the Aeron client for communication with the media driver
+     * Return the path to the CnC file used by the Aeron client for communication with the media driver.
      *
      * @return path of the CnC file
      */
@@ -209,7 +222,7 @@
     }

     /**
-     * Set the handler for exceptions from the Aeron client
+     * Set the handler for exceptions from the Aeron client.
      *
      * @param handler called when exceptions arise
      * @return reference to this Context instance
@@ -223,7 +236,7 @@
     }

     /**
-     * Set the handler for successful Aeron::addPublication notifications
+     * Set the handler for successful Aeron::addPublication notifications.
      *
      * @param handler called when add is completed successfully
      * @return reference to this Context instance
@@ -235,7 +248,7 @@
     }

     /**
-     * Set the handler for successful Aeron::addExclusivePublication notifications
+     * Set the handler for successful Aeron::addExclusivePublication notifications.
      *
      * If not set, then will use newPublicationHandler instead.
      *
@@ -250,7 +263,7 @@
     }

     /**
-     * Set the handler for successful Aeron::addSubscription notifications
+     * Set the handler for successful Aeron::addSubscription notifications.
      *
      * @param handler called when add is completed successfully
      * @return reference to this Context instance
@@ -262,7 +275,7 @@
     }

     /**
-     * Set the handler for available image notifications
+     * Set the handler for available image notifications.
      *
      * @param handler called when event occurs
      * @return reference to this Context instance
@@ -274,7 +287,7 @@
     }

     /**
-     * Set the handler for inactive image notifications
+     * Set the handler for inactive image notifications.
      *
      * @param handler called when event occurs
      * @return reference to this Context instance
@@ -286,7 +299,7 @@
     }

     /**
-     * Set the handler for available counter notifications
+     * Set the handler for available counter notifications.
      *
      * @param handler called when event occurs
      * @return reference to this Context instance
@@ -298,7 +311,7 @@
     }

     /**
-     * Set the handler for inactive counter notifications
+     * Set the handler for inactive counter notifications.
      *
      * @param handler called when event occurs
      * @return reference to this Context instance
@@ -311,8 +324,7 @@

     /**
      * Set the amount of time, in milliseconds, that this client will wait until it determines the
-     * Media Driver is unavailable. When this happens a
-     * DriverTimeoutException will be generated for the error handler.
+     * Media Driver is unavailable. When this happens a DriverTimeoutException will be generated for the error handler.
      *
      * @param value Number of milliseconds.
      * @return reference to this Context instance
@@ -326,8 +338,7 @@

     /**
      * Get the amount of time, in milliseconds, that this client will wait until it determines the
-     * Media Driver is unavailable. When this happens a
-     * DriverTimeoutException will be generated for the error handler.
+     * Media Driver is unavailable. When this happens a DriverTimeoutException will be generated for the error handler.
      *
      * @return value in number of milliseconds.
      * @see errorHandler


mfd: Add missing hunk to change palmas irq to clear on read

During conversion to regmap_irq this hunk was missing being moved
to MFD driver to put the chip into clear on read mode. Also as slave
is now set use it to determine which slave for the register call.

Signed-off-by: Graeme Gregory <f3226f91f77a87d909b8920adc91f9a301a7316b@slimlogic.co.uk>
Signed-off-by: Samuel Ortiz <0ba86cb3f08bbb861958e54bd3438887adb4263c@linux.intel.com>

--- drivers/mfd/palmas.c
+++ drivers/mfd/palmas.c
@@ -356,7 +356,14 @@
 		}
 	}

-	ret = regmap_add_irq_chip(palmas->regmap[1], palmas->irq,
+	/* Change IRQ into clear on read mode for efficiency */
+	slave = PALMAS_BASE_TO_SLAVE(PALMAS_INTERRUPT_BASE);
+	addr = PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE, PALMAS_INT_CTRL);
+	reg = PALMAS_INT_CTRL_INT_CLEAR;
+
+	regmap_write(palmas->regmap[slave], addr, reg);
+
+	ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq,
 			IRQF_ONESHOT | IRQF_TRIGGER_LOW, -1, &palmas_irq_chip,
 			&palmas->irq_data);
 	if (ret < 0)


mfd: palmas: Remove redundant of_match_ptr

'of_palmas_match_tbl' is always compiled in. Hence of_match_ptr() is
not needed.

Signed-off-by: Sachin Kamat <1c3b1584a6008857f36c03c58f657c0fc16fc09e@linaro.org>
Signed-off-by: Lee Jones <630e34333487a351a857f6b705e04d30b37c1629@linaro.org>

--- drivers/mfd/palmas.c
+++ drivers/mfd/palmas.c
@@ -403,7 +403,7 @@
 	palmas->dev = &i2c->dev;
 	palmas->irq = i2c->irq;

-	match = of_match_device(of_match_ptr(of_palmas_match_tbl), &i2c->dev);
+	match = of_match_device(of_palmas_match_tbl, &i2c->dev);

 	if (!match)
 		return -ENODATA;


8139cp: use PCI_DEVICE() to shorten the PCI device table

Signed-off-by: Francois Romieu <b6456b24ae82a7595be3173ae585c7a827f25f37@fr.zoreil.com>

--- drivers/net/8139cp.c
+++ drivers/net/8139cp.c
@@ -406,10 +406,8 @@
 			 struct ethtool_eeprom *eeprom, u8 *data);

 static struct pci_device_id cp_pci_tbl[] = {
-	{ PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139,
-	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-	{ PCI_VENDOR_ID_TTTECH, PCI_DEVICE_ID_TTTECH_MC322,
-	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
+	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK,	PCI_DEVICE_ID_REALTEK_8139), },
+	{ PCI_DEVICE(PCI_VENDOR_ID_TTTECH,	PCI_DEVICE_ID_TTTECH_MC322), },
 	{ },
 };
 MODULE_DEVICE_TABLE(pci, cp_pci_tbl);


of: mdio: fixup of_phy_register_fixed_link parsing of new bindings

Fixes commit 3be2a49e5c08 ("of: provide a binding for fixed link PHYs")

Fix the parsing of the new fixed link dts bindings for duplex,
pause, and asym_pause by using the correct device node pointer.

Signed-off-by: Richard Retanubun <3a834c992ef76dc5d4368afcccde659f5da4452e@gmail.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/of/of_mdio.c
+++ drivers/of/of_mdio.c
@@ -323,11 +323,13 @@
 	fixed_link_node = of_get_child_by_name(np, "fixed-link");
 	if (fixed_link_node) {
 		status.link = 1;
-		status.duplex = of_property_read_bool(np, "full-duplex");
+		status.duplex = of_property_read_bool(fixed_link_node,
+						      "full-duplex");
 		if (of_property_read_u32(fixed_link_node, "speed", &status.speed))
 			return -EINVAL;
-		status.pause = of_property_read_bool(np, "pause");
-		status.asym_pause = of_property_read_bool(np, "asym-pause");
+		status.pause = of_property_read_bool(fixed_link_node, "pause");
+		status.asym_pause = of_property_read_bool(fixed_link_node,
+							  "asym-pause");
 		of_node_put(fixed_link_node);
 		return fixed_phy_register(PHY_POLL, &status, np);
 	}


PCI: Add PCI quirk to disable L0s ASPM state for 82575 and 82598

This patch is intended to disable L0s ASPM link state for 82598 (ixgbe)
parts due to the fact that it is possible to corrupt TX data when coming
back out of L0s on some systems.  The workaround had been added for 82575
(igb) previously, but did not use the ASPM api.  This quirk uses the ASPM
api to prevent the ASPM subsystem from re-enabling the L0s state.

Instead of adding the fix in igb to the ixgbe driver as well it was
decided to move it into a pci quirk.  It is necessary to move the fix out
of the driver and into a pci quirk in order to prevent the issue from
occuring prior to driver load to handle the possibility of the device being
passed to a VM via direct assignment.

Signed-off-by: Alexander Duyck <af56634f9be8457194a3461ec96c497f138af4ff@intel.com>
Signed-off-by: Jeff Kirsher <87e35f5be20bb3e67f4ba6b86f5f6be3085b1b3a@intel.com>
CC: Jesse Barnes <bc7add126c2dbb8382bf1c28ac262b9363a32706@virtuousgeek.org>
Signed-off-by: Matthew Wilcox <990c37a323daf1549bdd24197927625080ee16b8@linux.intel.com>

--- drivers/pci/quirks.c
+++ drivers/pci/quirks.c
@@ -23,6 +23,7 @@
 #include <linux/acpi.h>
 #include <linux/kallsyms.h>
 #include <linux/dmi.h>
+#include <linux/pci-aspm.h>
 #include "pci.h"

 int isa_dma_bridge_buggy;
@@ -1749,6 +1750,30 @@
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_e100_interrupt);

+/*
+ * The 82575 and 82598 may experience data corruption issues when transitioning
+ * out of L0S.  To prevent this we need to disable L0S on the pci-e link
+ */
+static void __devinit quirk_disable_aspm_l0s(struct pci_dev *dev)
+{
+	dev_info(&dev->dev, "Disabling L0s\n");
+	pci_disable_link_state(dev, PCIE_LINK_STATE_L0S);
+}
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10a7, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10a9, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10b6, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c6, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c7, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c8, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10d6, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10db, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10dd, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10e1, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10ec, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f1, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f4, quirk_disable_aspm_l0s);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1508, quirk_disable_aspm_l0s);
+
 static void __devinit fixup_rev1_53c810(struct pci_dev* dev)
 {
 	/* rev 1 ncr53c810 chips don't set the class at all which means


[PARISC] [MUX] Mux driver bug fix

[PARISC] [MUX] Mux driver bug fix

This patch addresses the problems identified by Russell King in the
following email:

http://lists.parisc-linux.org/pipermail/parisc-linux/2005-December/027912.html

Signed-off-by: Ryan Bradetich <777b7d730cf8c8ed23f8c5b2305cdfb95607bdbb@parisc-linux.org>
Signed-off-by: Kyle McMartin <3c25b01657254677d3e1a8fd1f0742c5d489bd39@parisc-linux.org>

--- drivers/serial/mux.c
+++ drivers/serial/mux.c
@@ -51,7 +51,11 @@

 #define MUX_NR 256
 static unsigned int port_cnt __read_mostly;
-static struct uart_port mux_ports[MUX_NR];
+struct mux_port {
+	struct uart_port port;
+	int enabled;
+};
+static struct mux_port mux_ports[MUX_NR];

 static struct uart_driver mux_driver = {
 	.owner = THIS_MODULE,
@@ -250,7 +254,7 @@
  */
 static int mux_startup(struct uart_port *port)
 {
-	mod_timer(&mux_timer, jiffies + MUX_POLL_DELAY);
+	mux_ports[port->line].enabled = 1;
 	return 0;
 }

@@ -262,6 +266,7 @@
  */
 static void mux_shutdown(struct uart_port *port)
 {
+	mux_ports[port->line].enabled = 0;
 }

 /**
@@ -319,7 +324,7 @@
  * @port: Ptr to the uart_port.
  * @type: Bitmask of required configurations.
  *
- * Perform any autoconfiguration steps for the port.  This functino is
+ * Perform any autoconfiguration steps for the port.  This function is
  * called if the UPF_BOOT_AUTOCONF flag is specified for the port.
  * [Note: This is required for now because of a bug in the Serial core.
  *  rmk has already submitted a patch to linus, should be available for
@@ -357,11 +362,11 @@
 	int i;

 	for(i = 0; i < port_cnt; ++i) {
-		if(!mux_ports[i].info)
+		if(!mux_ports[i].enabled)
 			continue;

-		mux_read(&mux_ports[i]);
-		mux_write(&mux_ports[i]);
+		mux_read(&mux_ports[i].port);
+		mux_write(&mux_ports[i].port);
 	}

 	mod_timer(&mux_timer, jiffies + MUX_POLL_DELAY);
@@ -456,7 +461,7 @@
 	}

 	for(i = 0; i < ports; ++i, ++port_cnt) {
-		port = &mux_ports[port_cnt];
+		port = &mux_ports[port_cnt].port;
 		port->iobase	= 0;
 		port->mapbase	= dev->hpa.start + MUX_OFFSET +
 						(i * MUX_LINE_OFFSET);
@@ -484,6 +489,8 @@
 #ifdef CONFIG_SERIAL_MUX_CONSOLE
         register_console(&mux_console);
 #endif
+	mod_timer(&mux_timer, jiffies + MUX_POLL_DELAY);
+
 	return 0;
 }

@@ -520,9 +527,9 @@
 	int i;

 	for (i = 0; i < port_cnt; i++) {
-		uart_remove_one_port(&mux_driver, &mux_ports[i]);
-		if (mux_ports[i].membase)
-			iounmap(mux_ports[i].membase);
+		uart_remove_one_port(&mux_driver, &mux_ports[i].port);
+		if (mux_ports[i].port.membase)
+			iounmap(mux_ports[i].port.membase);
 	}

 	uart_unregister_driver(&mux_driver);


Char: nozomi, use GFP_KERNEL for kfifo allocation

The allocation was moved to probe function in 9842c38e9176. And we can
sleep there. So allocate the 4*8192 bytes as GFP_KERNEL to mitigate
the allocation failure.

Signed-off-by: Jiri Slaby <dfbf39eb5bf303a3db5454d815cb8c8888cbadf9@suse.cz>
Tested-by: Gerald Pfeifer <446f6fe420322ac611e4621119ab11e5a51daf2f@pfeifer.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/tty/nozomi.c
+++ drivers/tty/nozomi.c
@@ -1431,8 +1431,8 @@
 	}

 	for (i = PORT_MDM; i < MAX_PORT; i++) {
-		if (kfifo_alloc(&dc->port[i].fifo_ul,
-		      FIFO_BUFFER_SIZE_UL, GFP_ATOMIC)) {
+		if (kfifo_alloc(&dc->port[i].fifo_ul, FIFO_BUFFER_SIZE_UL,
+					GFP_KERNEL)) {
 			dev_err(&pdev->dev,
 					"Could not allocate kfifo buffer\n");
 			ret = -ENOMEM;


vhost-scsi: Make func indention more consistent

Signed-off-by: Asias He <7487d0432e24c09ba3f2ff7de44b9eb030d5ae18@redhat.com>
Signed-off-by: Michael S. Tsirkin <255103e50249e3d658441816e0597170ebfc16ef@redhat.com>

--- drivers/vhost/scsi.c
+++ drivers/vhost/scsi.c
@@ -328,11 +328,12 @@
 	return 1;
 }

-static u32 tcm_vhost_get_pr_transport_id(struct se_portal_group *se_tpg,
-	struct se_node_acl *se_nacl,
-	struct t10_pr_registration *pr_reg,
-	int *format_code,
-	unsigned char *buf)
+static u32
+tcm_vhost_get_pr_transport_id(struct se_portal_group *se_tpg,
+			      struct se_node_acl *se_nacl,
+			      struct t10_pr_registration *pr_reg,
+			      int *format_code,
+			      unsigned char *buf)
 {
 	struct tcm_vhost_tpg *tpg = container_of(se_tpg,
 				struct tcm_vhost_tpg, se_tpg);
@@ -358,10 +359,11 @@
 			format_code, buf);
 }

-static u32 tcm_vhost_get_pr_transport_id_len(struct se_portal_group *se_tpg,
-	struct se_node_acl *se_nacl,
-	struct t10_pr_registration *pr_reg,
-	int *format_code)
+static u32
+tcm_vhost_get_pr_transport_id_len(struct se_portal_group *se_tpg,
+				  struct se_node_acl *se_nacl,
+				  struct t10_pr_registration *pr_reg,
+				  int *format_code)
 {
 	struct tcm_vhost_tpg *tpg = container_of(se_tpg,
 				struct tcm_vhost_tpg, se_tpg);
@@ -387,10 +389,11 @@
 			format_code);
 }

-static char *tcm_vhost_parse_pr_out_transport_id(struct se_portal_group *se_tpg,
-	const char *buf,
-	u32 *out_tid_len,
-	char **port_nexus_ptr)
+static char *
+tcm_vhost_parse_pr_out_transport_id(struct se_portal_group *se_tpg,
+				    const char *buf,
+				    u32 *out_tid_len,
+				    char **port_nexus_ptr)
 {
 	struct tcm_vhost_tpg *tpg = container_of(se_tpg,
 				struct tcm_vhost_tpg, se_tpg);
@@ -416,8 +419,8 @@
 			port_nexus_ptr);
 }

-static struct se_node_acl *tcm_vhost_alloc_fabric_acl(
-	struct se_portal_group *se_tpg)
+static struct se_node_acl *
+tcm_vhost_alloc_fabric_acl(struct se_portal_group *se_tpg)
 {
 	struct tcm_vhost_nacl *nacl;

@@ -430,8 +433,9 @@
 	return &nacl->se_node_acl;
 }

-static void tcm_vhost_release_fabric_acl(struct se_portal_group *se_tpg,
-	struct se_node_acl *se_nacl)
+static void
+tcm_vhost_release_fabric_acl(struct se_portal_group *se_tpg,
+			     struct se_node_acl *se_nacl)
 {
 	struct tcm_vhost_nacl *nacl = container_of(se_nacl,
 			struct tcm_vhost_nacl, se_node_acl);
@@ -526,8 +530,9 @@
 	kfree(evt);
 }

-static struct tcm_vhost_evt *tcm_vhost_allocate_evt(struct vhost_scsi *vs,
-	u32 event, u32 reason)
+static struct tcm_vhost_evt *
+tcm_vhost_allocate_evt(struct vhost_scsi *vs,
+		       u32 event, u32 reason)
 {
 	struct vhost_virtqueue *vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq;
 	struct tcm_vhost_evt *evt;
@@ -571,8 +576,8 @@
 	kfree(tv_cmd);
 }

-static void tcm_vhost_do_evt_work(struct vhost_scsi *vs,
-	struct tcm_vhost_evt *evt)
+static void
+tcm_vhost_do_evt_work(struct vhost_scsi *vs, struct tcm_vhost_evt *evt)
 {
 	struct vhost_virtqueue *vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq;
 	struct virtio_scsi_event *event = &evt->event;
@@ -693,12 +698,12 @@
 		vhost_signal(&vs->dev, &vs->vqs[vq].vq);
 }

-static struct tcm_vhost_cmd *vhost_scsi_allocate_cmd(
-	struct vhost_virtqueue *vq,
-	struct tcm_vhost_tpg *tv_tpg,
-	struct virtio_scsi_cmd_req *v_req,
-	u32 exp_data_len,
-	int data_direction)
+static struct tcm_vhost_cmd *
+vhost_scsi_allocate_cmd(struct vhost_virtqueue *vq,
+			struct tcm_vhost_tpg *tv_tpg,
+			struct virtio_scsi_cmd_req *v_req,
+			u32 exp_data_len,
+			int data_direction)
 {
 	struct tcm_vhost_cmd *tv_cmd;
 	struct tcm_vhost_nexus *tv_nexus;
@@ -729,8 +734,11 @@
  *
  * Returns the number of scatterlist entries used or -errno on error.
  */
-static int vhost_scsi_map_to_sgl(struct scatterlist *sgl,
-	unsigned int sgl_count, struct iovec *iov, int write)
+static int
+vhost_scsi_map_to_sgl(struct scatterlist *sgl,
+		      unsigned int sgl_count,
+		      struct iovec *iov,
+		      int write)
 {
 	unsigned int npages = 0, pages_nr, offset, nbytes;
 	struct scatterlist *sg = sgl;
@@ -774,8 +782,11 @@
 	return ret;
 }

-static int vhost_scsi_map_iov_to_sgl(struct tcm_vhost_cmd *tv_cmd,
-	struct iovec *iov, unsigned int niov, int write)
+static int
+vhost_scsi_map_iov_to_sgl(struct tcm_vhost_cmd *tv_cmd,
+			  struct iovec *iov,
+			  unsigned int niov,
+			  int write)
 {
 	int ret;
 	unsigned int i;
@@ -855,8 +866,10 @@
 	}
 }

-static void vhost_scsi_send_bad_target(struct vhost_scsi *vs,
-	struct vhost_virtqueue *vq, int head, unsigned out)
+static void
+vhost_scsi_send_bad_target(struct vhost_scsi *vs,
+			   struct vhost_virtqueue *vq,
+			   int head, unsigned out)
 {
 	struct virtio_scsi_cmd_resp __user *resp;
 	struct virtio_scsi_cmd_resp rsp;
@@ -872,8 +885,8 @@
 		pr_err("Faulted on virtio_scsi_cmd_resp\n");
 }

-static void vhost_scsi_handle_vq(struct vhost_scsi *vs,
-	struct vhost_virtqueue *vq)
+static void
+vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
 {
 	struct tcm_vhost_tpg **vs_tpg;
 	struct virtio_scsi_cmd_req v_req;
@@ -1054,8 +1067,12 @@
 	pr_debug("%s: The handling func for control queue.\n", __func__);
 }

-static void tcm_vhost_send_evt(struct vhost_scsi *vs, struct tcm_vhost_tpg *tpg,
-	struct se_lun *lun, u32 event, u32 reason)
+static void
+tcm_vhost_send_evt(struct vhost_scsi *vs,
+		   struct tcm_vhost_tpg *tpg,
+		   struct se_lun *lun,
+		   u32 event,
+		   u32 reason)
 {
 	struct tcm_vhost_evt *evt;

@@ -1145,9 +1162,9 @@
  *  The lock nesting rule is:
  *    tcm_vhost_mutex -> vs->dev.mutex -> tpg->tv_tpg_mutex -> vq->mutex
  */
-static int vhost_scsi_set_endpoint(
-	struct vhost_scsi *vs,
-	struct vhost_scsi_target *t)
+static int
+vhost_scsi_set_endpoint(struct vhost_scsi *vs,
+			struct vhost_scsi_target *t)
 {
 	struct tcm_vhost_tport *tv_tport;
 	struct tcm_vhost_tpg *tv_tpg;
@@ -1235,9 +1252,9 @@
 	return ret;
 }

-static int vhost_scsi_clear_endpoint(
-	struct vhost_scsi *vs,
-	struct vhost_scsi_target *t)
+static int
+vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
+			  struct vhost_scsi_target *t)
 {
 	struct tcm_vhost_tport *tv_tport;
 	struct tcm_vhost_tpg *tv_tpg;
@@ -1397,8 +1414,10 @@
 	return 0;
 }

-static long vhost_scsi_ioctl(struct file *f, unsigned int ioctl,
-				unsigned long arg)
+static long
+vhost_scsi_ioctl(struct file *f,
+		 unsigned int ioctl,
+		 unsigned long arg)
 {
 	struct vhost_scsi *vs = f->private_data;
 	struct vhost_scsi_target backend;
@@ -1514,8 +1533,9 @@
 	return "Unknown";
 }

-static void tcm_vhost_do_plug(struct tcm_vhost_tpg *tpg,
-	struct se_lun *lun, bool plug)
+static void
+tcm_vhost_do_plug(struct tcm_vhost_tpg *tpg,
+		  struct se_lun *lun, bool plug)
 {

 	struct vhost_scsi *vs = tpg->vhost_scsi;
@@ -1555,7 +1575,7 @@
 }

 static int tcm_vhost_port_link(struct se_portal_group *se_tpg,
-	struct se_lun *lun)
+			       struct se_lun *lun)
 {
 	struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg,
 				struct tcm_vhost_tpg, se_tpg);
@@ -1574,7 +1594,7 @@
 }

 static void tcm_vhost_port_unlink(struct se_portal_group *se_tpg,
-	struct se_lun *lun)
+				  struct se_lun *lun)
 {
 	struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg,
 				struct tcm_vhost_tpg, se_tpg);
@@ -1590,10 +1610,10 @@
 	mutex_unlock(&tcm_vhost_mutex);
 }

-static struct se_node_acl *tcm_vhost_make_nodeacl(
-	struct se_portal_group *se_tpg,
-	struct config_group *group,
-	const char *name)
+static struct se_node_acl *
+tcm_vhost_make_nodeacl(struct se_portal_group *se_tpg,
+		       struct config_group *group,
+		       const char *name)
 {
 	struct se_node_acl *se_nacl, *se_nacl_new;
 	struct tcm_vhost_nacl *nacl;
@@ -1635,7 +1655,7 @@
 }

 static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tv_tpg,
-	const char *name)
+				const char *name)
 {
 	struct se_portal_group *se_tpg;
 	struct tcm_vhost_nexus *tv_nexus;
@@ -1739,7 +1759,7 @@
 }

 static ssize_t tcm_vhost_tpg_show_nexus(struct se_portal_group *se_tpg,
-	char *page)
+					char *page)
 {
 	struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg,
 				struct tcm_vhost_tpg, se_tpg);
@@ -1760,8 +1780,8 @@
 }

 static ssize_t tcm_vhost_tpg_store_nexus(struct se_portal_group *se_tpg,
-	const char *page,
-	size_t count)
+					 const char *page,
+					 size_t count)
 {
 	struct tcm_vhost_tpg *tv_tpg = container_of(se_tpg,
 				struct tcm_vhost_tpg, se_tpg);
@@ -1844,9 +1864,10 @@
 	NULL,
 };

-static struct se_portal_group *tcm_vhost_make_tpg(struct se_wwn *wwn,
-	struct config_group *group,
-	const char *name)
+static struct se_portal_group *
+tcm_vhost_make_tpg(struct se_wwn *wwn,
+		   struct config_group *group,
+		   const char *name)
 {
 	struct tcm_vhost_tport *tport = container_of(wwn,
 			struct tcm_vhost_tport, tport_wwn);
@@ -1902,9 +1923,10 @@
 	kfree(tpg);
 }

-static struct se_wwn *tcm_vhost_make_tport(struct target_fabric_configfs *tf,
-	struct config_group *group,
-	const char *name)
+static struct se_wwn *
+tcm_vhost_make_tport(struct target_fabric_configfs *tf,
+		     struct config_group *group,
+		     const char *name)
 {
 	struct tcm_vhost_tport *tport;
 	char *ptr;
@@ -1974,9 +1996,9 @@
 	kfree(tport);
 }

-static ssize_t tcm_vhost_wwn_show_attr_version(
-	struct target_fabric_configfs *tf,
-	char *page)
+static ssize_t
+tcm_vhost_wwn_show_attr_version(struct target_fabric_configfs *tf,
+				char *page)
 {
 	return sprintf(page, "TCM_VHOST fabric module %s on %s/%s"
 		"on "UTS_RELEASE"\n", TCM_VHOST_VERSION, utsname()->sysname,


xen: events: fix xen_map_pirq_gsi error return

Fix initial value of irq so that first goto out (if pirq or gsi
arguments are too large) actually returns an error.

Signed-off-by: Ian Campbell <9be92b3dbbd6611e3e4c9209fb3d04b4919e7cca@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <da3a51b335cef0eb0e2c329c5ef6bcd6acef687a@oracle.com>

--- drivers/xen/events.c
+++ drivers/xen/events.c
@@ -592,7 +592,7 @@
  */
 int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name)
 {
-	int irq = 0;
+	int irq = -1;
 	struct physdev_irq irq_op;

 	spin_lock(&irq_mapping_update_lock);


fixed issue 1586
false positive on browser_tests about noninherited_flags
- adjust check_and_not_test to report match on non-cbr-cti and aflags write inst

R=bruening@google.com
BUG=1586

Review URL: https://codereview.appspot.com/111090043

SVN-Revision: 1973

--- drmemory/readwrite.c
+++ drmemory/readwrite.c
@@ -2531,11 +2531,18 @@
         if (!safe_decode(drcontext, pc, &inst, &pc) ||
             !instr_valid(&inst))
             break;
-        /* #1576: call should be ok to continue */
-        if (instr_is_cbr(&inst) || instr_is_ubr(&inst))
+        /* for case like: and %ecx 0x80; jecxz */
+        if (instr_is_cbr(&inst))
             break;
         if (TESTANY(EFLAGS_READ_6, instr_get_eflags(&inst)))
             break;
+        if (/* report match on aflags written by other following instr */
+            TESTALL(EFLAGS_WRITE_6, instr_get_eflags(&inst)) ||
+            /* i#1576, i#1586: report match on non-cbr-cti */
+            instr_is_cti(&inst)) {
+            count = AND_NOT_TEST_INSTRS_TO_CHECK;
+            break;
+        }
         instr_reset(drcontext, &inst);
     }
     if (count == AND_NOT_TEST_INSTRS_TO_CHECK) {


Split out draw_percent().

Split out draw_percent().

--- battery.c
+++ battery.c
@@ -36,6 +36,15 @@
 		? GC_CRIT : GC_BAT;
 }

+static void draw_percent(struct XData * restrict X, const xcb_gc_t gc,
+	const uint8_t pct, const int16_t x)
+{
+	const uint8_t buf_sz = 7;
+	char buf[buf_sz];
+	const uint8_t l = snprintf(buf, buf_sz, " %d%% ", pct);
+	xcb_image_text_8(X->xcb, l, X->w, gc, x, X->font_size.h, buf);
+}
+
 void draw_battery(struct XData * restrict X, const uint16_t start,
 	const uint16_t end)
 {
@@ -52,11 +61,7 @@
 	xcb_poly_fill_rectangle(X->xcb, X->w, gc[GC_BG], 1, &g);
 	g.width = g.width * pct / 100;
 	xcb_poly_fill_rectangle(X->xcb, X->w, gc[a], 1, &g);
-	const uint8_t buf_sz = 7;
-	char buf[buf_sz];
-	const uint8_t l = snprintf(buf, buf_sz, " %d%% ", pct);
-	xcb_image_text_8(X->xcb, l, X->w, gc[a], start + (end-start)/2,
-		X->font_size.h, buf);
+	draw_percent(X, gc[a], pct, start + (end-start)/2);
 	xcb_flush(X->xcb);
 }


Complete on exercise3-3.c except for a-b-c cases


xy_symmetry - symmetry handling was exported into external function. Necessary preparation for more symmetry types support with more symmetrical activation (4 and 8).

--- bellman.c
+++ bellman.c
@@ -753,6 +753,35 @@
 	}
 }

+static int xy_symmetry(int x, int y, int* mirrorx_arr, int* mirrory_arr)
+{
+	mirrorx_arr[0] = x;
+	mirrory_arr[0] = y;
+
+	switch(symmetry_type) {
+		case NONE:
+			return 1;
+		case HORIZ:
+			if(y == symmetry_ofs - y)
+				return 1;
+
+			mirrorx_arr[1] = x;
+			mirrory_arr[1] = symmetry_ofs - y;
+
+			return 2;
+
+		case VERT:
+			if(x == symmetry_ofs - x)
+				return 1;
+
+			mirrorx_arr[1] =  symmetry_ofs - x;
+			mirrory_arr[1] = y;
+
+			return 2;
+
+	}
+}
+
 static void bellman_choose_cells(universe *u, generation *g) {
         // Look for a tile with some unknown cells.

@@ -882,34 +911,19 @@
 	x += dx;
 	y += dy;

-		int xmirror, ymirror;
-
-		switch(symmetry_type) {
-		case NONE:
-				xmirror = x;
-				ymirror = y;
-				break;
-
-		case HORIZ:
-				xmirror = x;
-				ymirror = symmetry_ofs - y;
-				break;
-
-		case VERT:
-				xmirror = symmetry_ofs - x;
-				ymirror = y;
-				break;
-
-		default: assert(0);
-		}
-
-		if(tile_get_cell(t->prev, xmirror, ymirror) != UNKNOWN_STABLE) {
+	int xmirror[8], ymirror[8], n_sym, i;
+
+	n_sym = xy_symmetry(x, y, xmirror, ymirror);
+
+	for(i = 0; i < n_sym; i++) {
+		if(tile_get_cell(t->prev, xmirror[i], ymirror[i]) != UNKNOWN_STABLE) {
 				fprintf(stderr, "Input region is asymmetric (%d,%d)=%d (%d,%d)=%d\n",
 						x, y, tile_get_cell(t->prev, x, y),
 						xmirror, ymirror, tile_get_cell(t->prev, xmirror, ymirror));
 				exit(-1);
 		}
-
+	}
+
 #if 0
 		tile_set_cell(t->prev, x, y, OFF);
 		tile_set_cell(t->auxdata, x, y, OFF);
@@ -918,49 +932,41 @@
 		RECURSE(("Recursing with (%d,%d) = OFF\n", x, y));
 		bellman_recurse(u, g->prev);
 #endif
-		int dn = 1;
-
-		//Symmetry many times turn ON 2 cells
-		if(xmirror != x || ymirror != y)
-			dn++;
-
-		if(n_live + dn <= max_live) {
-				tile_set_cell(t->prev, x, y, ON);
-				tile_set_cell((tile *)t->auxdata, x, y, ON);
-				tile_set_cell(t->prev, xmirror, ymirror, ON);
-				tile_set_cell((tile *)t->auxdata, xmirror, ymirror, ON);
-				g->prev->flags |= CHANGED;
-				RECURSE(("Recursing with (%d,%d) = ON\n", x, y));
-
-				n_live+=dn;
-					bellman_recurse(u, g->prev);
-				n_live-=dn;
+
+		if(n_live + n_sym <= max_live) {
+			for(i = 0; i < n_sym; i++){
+				tile_set_cell(t->prev,  xmirror[i], ymirror[i], ON);
+				tile_set_cell((tile *)t->auxdata,  xmirror[i], ymirror[i], ON);
+			}
+
+			g->prev->flags |= CHANGED;
+			RECURSE(("Recursing with (%d,%d) = ON\n", x, y));
+
+			n_live+=n_sym;
+				bellman_recurse(u, g->prev);
+			n_live-=n_sym;
 		} else {
 				PRUNE(("Too many live cells\n"));
 				prune_too_many_live++;
 		}
 #if 1
-		tile_set_cell(t->prev, x, y, OFF);
-		tile_set_cell((tile *)t->auxdata, x, y, OFF);
-		tile_set_cell(t->prev, xmirror, ymirror, OFF);
-		tile_set_cell((tile *)t->auxdata, xmirror, ymirror, OFF);
+		for(i = 0; i < n_sym; i++){
+			tile_set_cell(t->prev,  xmirror[i], ymirror[i], OFF);
+			tile_set_cell((tile *)t->auxdata,  xmirror[i], ymirror[i], OFF);
+		}
+
 		g->prev->flags |= CHANGED;

 		RECURSE(("Recursing with (%d,%d) = OFF\n", x, y));
-
-
 		bellman_recurse(u, g->prev);
 #endif
-
-
-		tile_set_cell(t->prev, x, y, UNKNOWN_STABLE);
-		tile_set_cell((tile *)t->auxdata, x, y, UNKNOWN_STABLE);
-		tile_set_cell(t->prev, xmirror, ymirror, UNKNOWN_STABLE);
-		tile_set_cell((tile *)t->auxdata, xmirror, ymirror, UNKNOWN_STABLE);
+
+		for(i = 0; i < n_sym; i++){
+			tile_set_cell(t->prev,  xmirror[i], ymirror[i], UNKNOWN_STABLE);
+			tile_set_cell((tile *)t->auxdata,  xmirror[i], ymirror[i], UNKNOWN_STABLE);
+		}
+
 		g->prev->flags |= CHANGED;
-
-
-
 }

 int main(int argc, char *argv[]) {


Missing null check

Missing null check

--- binding.c
+++ binding.c
@@ -58,6 +58,8 @@

   void *ptr = sodium_malloc(size);

+  SN_THROWS(ptr == NULL, "sodium_malloc failed");
+
   napi_value buf, key, value;

   SN_STATUS_THROWS(napi_create_external_buffer(env, size, ptr, &sn_sodium_free, NULL, &buf), "failed to create a n-api buffer")
@@ -138,7 +140,7 @@

   SN_ARGV_TYPEDARRAY(buf, 0)
   SN_ARGV_TYPEDARRAY(seed, 1)
-
+
   SN_ASSERT_LENGTH(seed_size, randombytes_SEEDBYTES, "seed")

   randombytes_buf_deterministic(buf_data, buf_size, seed_data);
@@ -1486,7 +1488,7 @@
   SN_ARGV(1, crypto_secretstream_xchacha20poly1305_keygen)

   SN_ARGV_TYPEDARRAY(k, 0)
-
+
   SN_ASSERT_LENGTH(k_size, crypto_secretstream_xchacha20poly1305_KEYBYTES, "k")

   crypto_secretstream_xchacha20poly1305_keygen(k_data);
@@ -1727,7 +1729,7 @@
   SN_ASSERT_MAX_LENGTH(opslimit, crypto_pwhash_OPSLIMIT_MAX, "opslimit")
   SN_ASSERT_MIN_LENGTH(memlimit, crypto_pwhash_MEMLIMIT_MIN, "memlimit")
   SN_ASSERT_MAX_LENGTH(memlimit, (int64_t) crypto_pwhash_MEMLIMIT_MAX, "memlimit")
-
+
   sn_async_pwhash_str_request *req = (sn_async_pwhash_str_request *) malloc(sizeof(sn_async_pwhash_str_request));
   req->out_data = out;
   req->pwd_data = pwd;
@@ -1888,7 +1890,7 @@
   SN_ASSERT_MAX_LENGTH(opslimit, crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit")
   SN_ASSERT_MIN_LENGTH(memlimit, crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit")
   SN_ASSERT_MAX_LENGTH(memlimit, (int64_t) crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit")
-
+
   sn_async_pwhash_scryptsalsa208sha256_request *req = (sn_async_pwhash_scryptsalsa208sha256_request *) malloc(sizeof(sn_async_pwhash_scryptsalsa208sha256_request));
   req->out_data = out;
   req->out_size = out_size;
@@ -1970,7 +1972,7 @@
   SN_ASSERT_MAX_LENGTH(opslimit, crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit")
   SN_ASSERT_MIN_LENGTH(memlimit, crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit")
   SN_ASSERT_MAX_LENGTH(memlimit, (int64_t) crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit")
-
+
   sn_async_pwhash_scryptsalsa208sha256_str_request *req = (sn_async_pwhash_scryptsalsa208sha256_str_request *) malloc(sizeof(sn_async_pwhash_scryptsalsa208sha256_str_request));
   req->out_data = out;
   req->pwd_data = pwd;


Minor update.

Minor update.

--- bitefan.h
+++ bitefan.h
@@ -618,7 +618,7 @@
 			}
 		}

-		return( sqrt( Dist ));
+		return( sqrt( Dist / ( ParamCount * ( FanSize - 1 ))));
 	}

 	/**


app: fix build with GCC 4.8

app: fix build with GCC 4.8

GCC 4.8 was producing this error:
	argument to ‘sizeof’ in ‘strncmp’ call is the same expression as the
	second source; did you mean to provide an explicit length?
	[-Werror=sizeof-pointer-memaccess]

Signed-off-by: Intel

--- app/test/test_cmdline_string.c
+++ app/test/test_cmdline_string.c
@@ -383,7 +383,7 @@
 			return -1;
 		}
 		if (strncmp(buf, string_elt_strs[i].result,
-				sizeof(string_elt_strs[i].result)) != 0) {
+				sizeof(buf)) != 0) {
 			printf("Error: result mismatch!\n");
 			return -1;
 		}


Fix packing of NULL strings (causing problems under Solaris)

git-svn-id: d023f1085a36f7a677188d00334e37d38ffecf51@112 64e312b2-a51f-0410-8e61-82d0ca0eb02a

--- check/src/check_pack.c
+++ check/src/check_pack.c
@@ -138,22 +138,26 @@
     strsz = strlen (val) + 1;

   pack_int(buf,strsz);
-  n = sprintf (*buf, "%s", val);
-
-  *buf += n + 1;
+  if (strsz > 0) {
+    n = sprintf (*buf, "%s", val);
+    *buf += n + 1;
+  }
+
 }

 static char *upack_str (char **buf)
 {
-  char *val;
+  char *val = NULL;
   int strsz;

   val = emalloc (CK_MAXMSG);

   strsz = upack_int (buf);
-
-  strncpy (val, *buf, strsz);
-  *buf += strsz;
+
+  if (strsz > 0) {
+    strncpy (val, *buf, strsz);
+    *buf += strsz;
+  }

   return val;
 }


Chris Nystrom helped me realize I must count the received bytes myself to know when the transfer is complete

--- example/simple/scp.c
+++ example/simple/scp.c
@@ -1,5 +1,5 @@
 /*
- * $Id: scp.c,v 1.2 2007/01/30 11:10:26 bagder Exp $
+ * $Id: scp.c,v 1.3 2007/02/01 22:39:45 bagder Exp $
  *
  * Sample showing how to do a simple SCP transfer.
  */
@@ -32,6 +32,7 @@
 	char *scppath=(char *)"/tmp/TEST";
 	struct stat fileinfo;
 	int rc;
+	off_t got=0;

 #ifdef WIN32
 	WSADATA wsadata;
@@ -116,16 +117,26 @@
 		goto shutdown;
 	}

-	do {
+
+	while(got < fileinfo.st_size) {
 		char mem[1024];
-		/* loop until we fail */
-		rc = libssh2_channel_read(channel, mem, sizeof(mem));
-		fprintf(stderr, "libssh2_channel_read returned %d\n",
-			rc);
-		if(rc > 0) {
+		int amount=sizeof(mem);
+
+		if((fileinfo.st_size -got) < amount) {
+			amount = fileinfo.st_size -got;
+		}
+
+		rc = libssh2_channel_read(channel, mem, amount);
+		if(rc == amount) {
 			write(2, mem, rc);
 		}
-	} while (rc > 0);
+		else {
+			fprintf(stderr, "libssh2_channel_read() failed: %d\n",
+				rc);
+			break;
+		}
+		got += rc;
+	}

 	libssh2_channel_free(channel);
 	channel = NULL;


eve: improve example 3

eve: improve example 3

Signed-off-by: Francois Berder <59eaf4bb0211c66c3d7532da6d77ecf42a779d82@outlook.fr>

--- examples/eve/main3.c
+++ examples/eve/main3.c
@@ -1,6 +1,8 @@
 /**
  * This example shows some graphic capabilities of the EVE Click wrapper of the
- * LetMeCreate library.
+ * LetMeCreate library. You can find more documentation about these commands in
+ * the programmer guide available on FTDI website:
+ * http://www.ftdichip.com/Support/Documents/ProgramGuides/FT800%20Programmers%20Guide.pdf
  *
  * It displays some text, a button, a gauge, a clock, a dial and a toogle. After
  *  10 seconds, it exits.


Formatting.

Formatting.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@183807 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/CodeGen/AsmPrinter/DIE.h
+++ lib/CodeGen/AsmPrinter/DIE.h
@@ -274,7 +274,7 @@

     /// getValue - Get MCSymbol.
     ///
-    const MCSymbol *getValue()       const { return Label; }
+    const MCSymbol *getValue() const { return Label; }

     /// SizeOf - Determine size of label value in bytes.
     ///


Making SharedArrayBuffer to be experimental

--- lib/Common/ConfigFlagsList.h
+++ lib/Common/ConfigFlagsList.h
@@ -570,7 +570,12 @@
 #define DEFAULT_CONFIG_ES7TrailingComma        (true)
 #define DEFAULT_CONFIG_ES7ValuesEntries        (true)
 #define DEFAULT_CONFIG_ESObjectGetOwnPropertyDescriptors (true)
+
+#ifdef COMPILE_DISABLE_ESSharedArrayBuffer
 #define DEFAULT_CONFIG_ESSharedArrayBuffer     (false)
+#else
+#define DEFAULT_CONFIG_ESSharedArrayBuffer     (false)
+#endif
 #define DEFAULT_CONFIG_ES6Verbose              (false)
 #define DEFAULT_CONFIG_ES6All                  (false)
 // ES6 DEFAULT BEHAVIOR
@@ -785,7 +790,7 @@
 // Release flags with parent and acronym
 #ifndef FLAGPRA
 #define FLAGPRA(Type, ParentName, Name, Acronym, String, Default) \
-        FLAGPR(Type, ParentName, Name, String, Default) \
+        FLAG_REGOVR_EXP(Type, Name, String, Default, ParentName, FALSE) \
         FLAGNR(Type, Acronym, String, Default)
 #endif

@@ -1017,6 +1022,10 @@
 FLAGPR_REGOVR_EXP(Boolean, ES6, ArrayBufferTransfer    , "Enable ArrayBuffer.transfer"                              , DEFAULT_CONFIG_ArrayBufferTransfer)

 FLAGPR           (Boolean, ES6, ESObjectGetOwnPropertyDescriptors, "Enable Object.getOwnPropertyDescriptors"        , DEFAULT_CONFIG_ESObjectGetOwnPropertyDescriptors)
+
+#ifndef COMPILE_DISABLE_ESSharedArrayBuffer
+    #define COMPILE_DISABLE_ESSharedArrayBuffer 0
+#endif
 FLAGPRA          (Boolean, ES6, ESSharedArrayBuffer    , sab     , "Enable SharedArrayBuffer"                       , DEFAULT_CONFIG_ESSharedArrayBuffer)

 // /ES6 (BLUE+1) features/flags


Added new header for common internal definitions.  These are all performance- related at the moment.

error: pathspec 'expat/lib/internal.h' did not match any file(s) known to git

--- expat/lib/internal.h
+++ expat/lib/internal.h
@@ -0,0 +1,37 @@
+/* internal.h
+
+   Internal definitions used by Expat.  This is not needed to compile
+   client code.
+
+   The following definitions are made:
+
+   FASTCALL -- Used for most internal functions to specify that the
+               fastest possible calling convention be used.
+
+   inline   -- Used for selected internal functions for which inlining
+               may improve performance on some platforms.
+*/
+
+#if defined(__GNUC__)
+#define FASTCALL __attribute__((stdcall, regparm(3)))
+#elif defined(WIN32)
+#define FASTCALL __fastcall
+#else
+#define FASTCALL
+#endif
+
+#ifndef XML_MIN_SIZE
+#if !defined(__cplusplus) && !defined(inline)
+#ifdef __GNUC__
+#define inline __inline
+#endif /* __GNUC__ */
+#endif
+#endif /* XML_MIN_SIZE */
+
+#ifdef __cplusplus
+#define inline inline
+#else
+#ifndef inline
+#define inline
+#endif
+#endif


Suppress a warning from GCC that moveToFreeBindingList() had no prototype, by making it static.

--- expat/lib/xmlparse.c
+++ expat/lib/xmlparse.c
@@ -775,7 +775,8 @@
 }

 /* moves list of bindings to freeBindingList */
-void moveToFreeBindingList(XML_Parser parser, BINDING *bindings)
+static void
+moveToFreeBindingList(XML_Parser parser, BINDING *bindings)
 {
   while (bindings) {
     BINDING *b = bindings;


xmlparse.c: Limit declaration of rand_s to mingwrt <5.3.0

--- expat/lib/xmlparse.c
+++ expat/lib/xmlparse.c
@@ -737,9 +737,11 @@
 #ifdef _WIN32

 /* Provide declaration of rand_s() for MinGW-32 (not 64, which has it),
-   as it doesn't declare it in its header up to at least 5.2.2 version
-   of its runtime package (mingwrt, containing stdlib.h). */
-#  if defined(__MINGW32__) && ! defined(__MINGW64_VERSION_MAJOR)
+   as it didn't declare it in its header prior to version 5.3.0 of its
+   runtime package (mingwrt, containing stdlib.h).  The upstream fix
+   was introduced at https://osdn.net/projects/mingw/ticket/39658 . */
+#  if defined(__MINGW32__) && defined(__MINGW32_VERSION)                       \
+      && __MINGW32_VERSION < 5003000L && ! defined(__MINGW64_VERSION_MAJOR)
 __declspec(dllimport) int rand_s(unsigned int *);
 #  endif


Change rm_write_temp_image to check for an exception in SetImageRegistry before testing its return value. SetImageRegistry usually establishes a meaningful error message if it fails.

--- ext/RMagick/rmutil.c
+++ ext/RMagick/rmutil.c
@@ -1,4 +1,4 @@
-/* $Id: rmutil.c,v 1.86 2007/01/12 00:11:20 rmagick Exp $ */
+/* $Id: rmutil.c,v 1.87 2007/01/13 21:12:19 rmagick Exp $ */
 /*============================================================================\
 |                Copyright (C) 2007 by Timothy P. Hunter
 | Name:     rmutil.c
@@ -2902,11 +2902,11 @@
     long registry_id;

     registry_id = SetMagickRegistry(ImageRegistryType, image, sizeof(Image), &image->exception);
+    rm_check_image_exception(image, RetainOnError);
     if (registry_id < 0)
     {
         rb_raise(rb_eRuntimeError, "SetMagickRegistry failed.");
     }
-    rm_check_image_exception(image, RetainOnError);

     sprintf(tmpnam, "mpri:%ld", registry_id);
 }


Added parenthesis to avoid warning messages.

--- ext/f2c_libs/lread.c
+++ ext/f2c_libs/lread.c
@@ -107,7 +107,7 @@
 int f__lcount,f__ltype,nml_read;
 char *f__lchar;
 double f__lx,f__ly;
-#define ERR(x) if(n=(x)) return(n)
+#define ERR(x) if((n=(x))) return(n)
 #define GETC(x) (x=(*l_getc)())
 #define Ungetc(x,y) (*l_ungetc)(x,y)

@@ -292,11 +292,12 @@
 			f__lquit = 2;
 			return 0;
 			}
-		if (rd_count(ch))
+		if (rd_count(ch)) {
 			if(!f__cf || !feof(f__cf))
 				errfl(f__elist->cierr,112,"complex format");
 			else
 				err(f__elist->cierr,(EOF),"lread");
+                }
 		if(GETC(ch)!='*')
 		{
 			if(!f__cf || !feof(f__cf))
@@ -315,7 +316,7 @@
 	Ungetc(ch,f__cf);
 	nml_save = nml_read;
 	nml_read = 0;
-	if (ch = l_R(1,0))
+	if ((ch = l_R(1,0)))
 		return ch;
 	if (!f__ltype)
 		errfl(f__elist->cierr,112,"no real part");
@@ -327,7 +328,7 @@
 	}
 	while(iswhit(GETC(ch)));
 	(void) Ungetc(ch,f__cf);
-	if (ch = l_R(1,0))
+	if ((ch = l_R(1,0)))
 		return ch;
 	if (!f__ltype)
 		errfl(f__elist->cierr,112,"no imaginary part");
@@ -354,7 +355,7 @@
 nmL_getc(Void)
 {
 	int rv;
-	if (rv = *nmL_next++)
+	if ((rv = *nmL_next++))
 		return rv;
 	l_getc = nmL_getc_save;
 	l_ungetc = nmL_ungetc_save;
@@ -436,11 +437,12 @@
 	if(isdigit(ch))
 	{
 		rd_count(ch);
-		if(GETC(ch)!='*')
+		if(GETC(ch)!='*') {
 			if(!f__cf || !feof(f__cf))
 				errfl(f__elist->cierr,112,"no star");
 			else
 				err(f__elist->cierr,(EOF),"lread");
+                }
 		GETC(ch);
 	}
 	sawdot = 0;
@@ -788,7 +790,7 @@
 	f__reading=1;
 	f__external=1;
 	f__formatted=1;
-	if(n=c_le(a)) return(n);
+	if((n=c_le(a))) return(n);
 	f__lioproc = l_read;
 	f__lquit = 0;
 	f__lcount = 0;


Validate that the input parameter to scheduler_parameters is an ARRAY.

Signed-off-by: Chris Lalancette <60b62644009db6b194cc0445b64e9b27bb26433a@redhat.com>

--- ext/libvirt/domain.c
+++ ext/libvirt/domain.c
@@ -1764,6 +1764,8 @@
     int r;
     int i;
     VALUE val;
+
+    Check_Type(input, T_ARRAY);

     dom = domain_get(d);


Block and hide images by domain and relative path

--- extensions/adblock.c
+++ extensions/adblock.c
@@ -53,9 +53,8 @@
         "   for (var i in sites) {"
         "       if (URL.indexOf(i) != -1) {"
         "           public += sites[i];"
-        "           break;"
+        "           public += ' {display: none !important}';"
         "   }}"
-        "   public += ' {display: none !important;}';"
         "   var mystyle = document.createElement('style');"
         "   mystyle.setAttribute('type', 'text/css');"
         "   mystyle.setAttribute('id', 'madblock');"
@@ -79,7 +78,7 @@
     keys = g_hash_table_new_full (g_str_hash, g_str_equal,
                    (GDestroyNotify)g_free,
                    (GDestroyNotify)g_regex_unref);
-    katze_assign (blockcss, g_strdup ("z-non-exist"));
+    katze_assign (blockcss, g_strdup ("z-non-exist {display: none !important};"));
     katze_assign (blockcssprivate, g_strdup (""));
 }

@@ -704,9 +703,18 @@
 adblock_custom_block_image_cb (GtkWidget*       widget,
                                MidoriExtension* extension)
 {
+    WebKitWebView* web_view;
+    const gchar* req_uri;
+    gchar* custom_list;
     FILE* list;
-    gchar* custom_list;
+    SoupURI* s_req_domain;
     gchar* uri;
+    SoupURI* s_uri;
+
+    web_view = g_object_get_data (G_OBJECT (widget), "webview");
+    req_uri = webkit_web_view_get_uri (web_view);
+    if (!req_uri)
+        return;

     custom_list = g_build_filename (midori_extension_get_config_dir (extension),
                                     CUSTOM_LIST_NAME, NULL);
@@ -715,11 +723,17 @@
         g_free (custom_list);
         return;
     }
+    s_req_domain = soup_uri_new (req_uri);
     uri = g_object_get_data (G_OBJECT (widget), "uri");
+    s_uri = soup_uri_new (uri);
+
     g_fprintf (list, "%s\n", uri);
-    g_fprintf (list, "##img[src=\"%s\"]\n", uri);
+    g_fprintf (list, "%s##img[src*=\"%s\"]\n", s_req_domain->host, s_uri->path);
     fclose (list);
-    adblock_parse_file (custom_list);
+    adblock_reload_rules (extension);
+
+    soup_uri_free (s_req_domain);
+    soup_uri_free (s_uri);
     g_free (custom_list);
 }

@@ -747,6 +761,7 @@
     gtk_widget_show (menuitem);
     gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
     g_object_set_data_full (G_OBJECT (menuitem), "uri", uri, (GDestroyNotify)g_free);
+    g_object_set_data (G_OBJECT (menuitem), "webview", web_view);
     g_signal_connect (menuitem, "activate",
         G_CALLBACK (adblock_custom_block_image_cb), extension);
 }
@@ -978,7 +993,7 @@

     (void)*line++;
     (void)*line++;
-    new_blockcss = g_strdup_printf ("%s, %s", blockcss, line);
+    new_blockcss = g_strdup_printf ("%s; %s {display: none !important}", blockcss, line);
     katze_assign (blockcss, new_blockcss);
 }


Fix off by 1 in ASN1_STRING_set()

Fix off by 1 in ASN1_STRING_set()

Reviewed-by: Rich Salz <rsalz@openssl.org>

MR: #3176

--- crypto/asn1/asn1_lib.c
+++ crypto/asn1/asn1_lib.c
@@ -271,7 +271,7 @@
         else
             len = strlen(data);
     }
-    if ((str->length < len) || (str->data == NULL)) {
+    if ((str->length <= len) || (str->data == NULL)) {
         c = str->data;
         str->data = OPENSSL_realloc(c, len + 1);
         if (str->data == NULL) {


PR: 1990

PR: 1990

Update from 0.9.8-stable

--- crypto/bio/bss_dgram.c
+++ crypto/bio/bss_dgram.c
@@ -250,17 +250,22 @@
 	{
 #if defined(SO_RCVTIMEO)
 	bio_dgram_data *data = (bio_dgram_data *)b->ptr;
+
+	/* Is a timer active? */
+	if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0)
+		{
 #ifdef OPENSSL_SYS_WINDOWS
-	int timeout = data->socket_timeout.tv_sec * 1000 +
-				  data->socket_timeout.tv_usec / 1000;
-	if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
-				   (void*)&timeout, sizeof(timeout)) < 0)
-		{ perror("setsockopt"); }
-#else
-	if ( setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, &(data->socket_timeout),
-					sizeof(struct timeval)) < 0)
-		{ perror("setsockopt"); }
-#endif
+		int timeout = data->socket_timeout.tv_sec * 1000 +
+					  data->socket_timeout.tv_usec / 1000;
+		if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
+					   (void*)&timeout, sizeof(timeout)) < 0)
+			{ perror("setsockopt"); }
+#else
+		if ( setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, &(data->socket_timeout),
+						sizeof(struct timeval)) < 0)
+			{ perror("setsockopt"); }
+#endif
+		}
 #endif
 	}