free とか使いたくない。 realloc 使おう。

free とか使いたくない。 realloc 使おう。

--- parser/formula.c
+++ parser/formula.c
@@ -26,6 +26,7 @@

 static int BUFSIZE;
 static char **buffer;
+static char *buffered;
 static char **variables;
 static int BUFTOP = 0;
 static int bufptr = 0;
@@ -45,17 +46,17 @@
 }

 static inline void finish_line () {
-  if ( ! buffer[BUFTOP] )
+  if ( ! buffered[BUFTOP] )
     return;

-  free ( buffer[BUFTOP] );
-  buffer[BUFTOP] = NULL;
+  buffer[BUFTOP][0] = '\0';
+  buffered[BUFTOP] = 0;

   incr_BUFTOP();
 }

 static inline void retry() {
-  if ( ! buffer[BUFTOP] )
+  if ( ! buffered[BUFTOP] )
     return;

   printf ( "%s\n", buffer[BUFTOP] );
@@ -106,6 +107,7 @@

   BUFSIZE   = argc - 2;
   buffer    = calloc(sizeof(char *), BUFSIZE);
+  buffered  = calloc(sizeof(char), BUFSIZE);
   variables = calloc(sizeof(char *), BUFSIZE);

   const int formulavlen = flvlen(FORMULAV);
@@ -126,7 +128,7 @@
       continue;
     }

-    if ( ! buffer[bufptr] ) {
+    if ( ! buffered[bufptr] ) {

       if ( getline( &line, &len, stdin ) == -1 ) {
         finish_failure();
@@ -146,9 +148,10 @@
           return 0;
         }

-        buffer[bufptr] = malloc(sizeof(char) * x);
+        buffer[bufptr] = realloc(buffer[bufptr], sizeof(char) * (x + 1));
         memcpy( buffer[bufptr], line, x );
         buffer[bufptr][x] = '\0';
+        buffered[bufptr] = 1;
       }
     }


Adapts the device name to the new way.

Adapts the device name to the new way.

--- hcid/device.c
+++ hcid/device.c
@@ -763,7 +763,7 @@
 	if (device == NULL)
 		return NULL;

-	device->path = g_strdup_printf("/device/%s_%s", adapter, address);
+	device->path = g_strdup_printf("%s/dev_%s", adapter, address);
 	g_strdelimit(device->path, ":", '_');

 	debug("Creating device %s", device->path);


print info in help that we are not doing nc

--- hcxhashtool.c
+++ hcxhashtool.c
@@ -998,7 +998,9 @@
 	"--info=stdout          : stdout output detailed information about content of hash file\n"
 	"--psk=<PSK>            : pre-shared key to test\n"
 	"                       : due to PBKDF2 calculation this is a very slow process\n"
+	"                       : no nonce error corrections\n"
 	"--pmk=<PMK>            : plain master key to test\n"
+	"                       : no nonce error corrections\n"
 	"--help                 : show this help\n"
 	"--version              : show version\n"
 	"\n", eigenname, VERSION, VERSION_JAHR, eigenname, ESSID_LEN_MIN, ESSID_LEN_MAX, ESSID_LEN_MIN, ESSID_LEN_MAX);


fixed filename ptr issue

fixed filename ptr issue

--- hcxhashtool.c
+++ hcxhashtool.c
@@ -195,9 +195,9 @@

 for(zeiger = hashlist; zeiger < hashlist +pmkideapolcount; zeiger++)
 	{
+	groupoutname[0] = 0;
 	if((zeiger->essidlen < essidlenmin) || (zeiger->essidlen > essidlenmax)) continue;
 	if(((zeiger->type &hashtype) != HCX_TYPE_PMKID) && ((zeiger->type &hashtype) != HCX_TYPE_EAPOL)) continue;
-
 	ceo = 0;
 	for (cei = 0; cei < zeiger->essidlen; cei++)
 		{
@@ -215,7 +215,7 @@
 		}
 	writepmkideapolhashline(fh_pmkideapol, zeiger);
 	if(fh_pmkideapol != NULL) fclose(fh_pmkideapol);
-	if(groupoutname != NULL)
+	if(groupoutname[0] != 0)
 		{
 		if(stat(groupoutname, &statinfo) == 0)
 			{


Fixed typo in help: uing > using

Fixed typo in help: uing > using

--- hcxpcaptool.c
+++ hcxpcaptool.c
@@ -6432,7 +6432,7 @@
 	"--hccap-out=<file>                : output old hccap file (hashcat -m 2500)\n"
 	"--hccap-raw-out=<file>            : output raw old hccap file (hashcat -m 2500)\n"
 	"                                    very slow!\n"
-	"--prefix-out=<file>               : convert everything to lists uing this prefix (overrides single options):\n"
+	"--prefix-out=<file>               : convert everything to lists using this prefix (overrides single options):\n"
 	"                                    hccapx (-o) file.hccapx\n"
 	"                                    PMKID (-k) file.16800\n"
 	"                                    netntlm (--netntlm-out) file.5500\n"


take ESSID also proberequest

take ESSID also proberequest

--- hcxpcaptool.c
+++ hcxpcaptool.c
@@ -711,7 +711,7 @@
 				{
 				if(memcmp(zeiger->mac_ap, zeigeressid->mac_ap, 6) == 0)
 					{
-					if((zeigeressid->status != 1) && (memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0))
+					if(memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0)
 						{
 						zeiger->essidlen = zeigeressid->essidlen;
 						memset(zeiger->essid, 0, 32);
@@ -757,7 +757,7 @@
 				{
 				if(memcmp(zeiger->mac_ap, zeigeressid->mac_ap, 6) == 0)
 					{
-					if((zeigeressid->status != 1) && (memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0))
+					if(memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0)
 						{
 						zeiger->essidlen = zeigeressid->essidlen;
 						memset(zeiger->essid, 0, 32);
@@ -803,7 +803,7 @@
 				{
 				if(memcmp(zeiger->mac_ap, zeigeressid->mac_ap, 6) == 0)
 					{
-					if((zeigeressid->status != 1) && (memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0))
+					if(memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0)
 						{
 						zeiger->essidlen = zeigeressid->essidlen;
 						memset(zeiger->essid, 0, 32);
@@ -849,7 +849,7 @@
 				{
 				if(memcmp(zeiger->mac_ap, zeigeressid->mac_ap, 6) == 0)
 					{
-					if((zeigeressid->status != 1) && (memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0))
+					if(memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0)
 						{
 						zeiger->essidlen = zeigeressid->essidlen;
 						memset(zeiger->essid, 0, 32);
@@ -895,7 +895,7 @@
 				{
 				if(memcmp(zeiger->mac_ap, zeigeressid->mac_ap, 6) == 0)
 					{
-					if((zeigeressid->status != 1) && (memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0))
+					if(memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0)
 						{
 						zeiger->essidlen = zeigeressid->essidlen;
 						memset(zeiger->essid, 0, 32);
@@ -941,7 +941,7 @@
 				{
 				if(memcmp(zeiger->mac_ap, zeigeressid->mac_ap, 6) == 0)
 					{
-					if((zeigeressid->status != 1) && (memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0))
+					if(memcmp(&essidold, zeigeressid->essid, zeigeressid->essidlen) != 0)
 						{
 						zeiger->essidlen = zeigeressid->essidlen;
 						memset(zeiger->essid, 0, 32);


hdata/spira.c: Add device-tree bindings for nest mmu

The nest mmu will only get initialised by opal_nmmu_set_ptcr() if the
appropriate device-tree entries exist. Add them during hdata parsing.

Signed-off-by: Alistair Popple <e9adbcf81c8a36ccc628e09bc92d0e25e1c8e501@popple.id.au>
Acked-by: Oliver O'Halloran <3dfaff8fa6ae977f042064a112a6aac576279b9b@gmail.com>
Signed-off-by: Stewart Smith <ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.vnet.ibm.com>

--- hdata/spira.c
+++ hdata/spira.c
@@ -791,6 +791,20 @@
 	}
 }

+static void add_nmmu(void)
+{
+	struct dt_node *xscom, *nmmu;
+
+	/* Nest MMU only exists on POWER9 */
+	if (proc_gen != proc_gen_p9)
+		return;
+
+	dt_for_each_compatible(dt_root, xscom, "ibm,xscom") {
+		nmmu = dt_new_addr(xscom, "nmmu", 0x5012c40);
+		dt_add_property_strings(nmmu, "compatible", "ibm,power9-nest-mmu");
+		dt_add_property_cells(nmmu, "reg", 0x5012c40, 0x20);
+	}
+}

 static void add_iplparams_sys_params(const void *iplp, struct dt_node *node)
 {
@@ -1265,6 +1279,9 @@
 	/* Add NX */
 	add_nx();

+	/* Add nest mmu */
+	add_nmmu();
+
 	/* Add IO HUBs and/or PHBs */
 	io_parse();


Only print SPIRA discovered serial port info at PR_INFO priority

It's certainly not an error that we have a serial port, and not
essential to display during boot. Odds are, you already know
about the serial port.

Signed-off-by: Stewart Smith <ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.vnet.ibm.com>

--- hdata/spira.c
+++ hdata/spira.c
@@ -777,7 +777,7 @@
 		prerror("IPLPARAMS: No serial ports\n");
 		return;
 	}
-	prerror("IPLPARAMS: %d serial ports in array\n", count);
+	prlog(PR_INFO, "IPLPARAMS: %d serial ports in array\n", count);

 	node = dt_new(node, "fsp-serial");
 	assert(node);
@@ -791,8 +791,8 @@
 		if (!CHECK_SPPTR(ipser))
 			continue;
 		rsrc_id = be16_to_cpu(ipser->rsrc_id);
-		printf("IPLPARAMS: Serial %d rsrc: %04x loc: %s\n",
-		       i, rsrc_id, ipser->loc_code);
+		prlog(PR_INFO, "IPLPARAMS: Serial %d rsrc: %04x loc: %s\n",
+		      i, rsrc_id, ipser->loc_code);
 		ser_node = dt_new_addr(node, "serial", rsrc_id);
 		if (!ser_node)
 			continue;


add missing return value

add missing return value

git-svn-id: 40192aece4a9e6664bc9a93aa558322db432a344@1387 15ae5fad-cc11-0410-8fac-bce609e504b0

--- cxxtools/include/cxxtools/posix/exec.h
+++ cxxtools/include/cxxtools/posix/exec.h
@@ -80,6 +80,8 @@
           arg.copy(args[argc], arg.size());
           args[argc][arg.size()] = '\0';
           args[argc + 1] = args[argc] + arg.size() + 1;
+
+          return *this;
         }

         // nice alias of push_back


parse for cone cylinder & plane

parse for cone cylinder & plane

--- srcs/parsing/p_objects.c
+++ srcs/parsing/p_objects.c
@@ -3,10 +3,10 @@
 /*                                                        :::      ::::::::   */
 /*   p_objects.c                                        :+:      :+:    :+:   */
 /*                                                    +:+ +:+         +:+     */
-/*   By: bbeldame <bbeldame@student.42.fr>          +#+  +:+       +#+        */
+/*   By: tfaure <tfaure@student.42.fr>              +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2017/04/15 21:47:24 by bbeldame          #+#    #+#             */
-/*   Updated: 2017/04/18 17:43:15 by bbeldame         ###   ########.fr       */
+/*   Updated: 2017/04/19 17:09:56 by tfaure           ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */

@@ -46,15 +46,96 @@

 void		set_plane(t_env *e)
 {
-	ft_putstr("Cool plane");
+	static t_object		*plane;
+	char				*option;
+	char				*option_arg;
+
+	if (!plane)
+		plane = (t_object *)semalloc(sizeof(t_object));
+	plane->type = PLANE;
+	e->nbline++;
+	if (get_next_line(e->fd, &option) == 1 && option[0] == ' ')
+	{
+		option = trim_option(e, option, &option_arg);
+		if (!ft_strcmp("origin", option))
+			plane->origin = set_vector(e, option_arg);
+		else if (!ft_strcmp("radius", option))
+			plane->radius = ft_atoi(option_arg);
+		else if (!ft_strcmp("color", option))
+			plane->color = set_color(e, option_arg);
+		else
+			unknown_option(option, e->nbline, "plane");
+		free(option);
+		set_plane(e);
+	}
+	else
+	{
+		set_last_obj(e, plane);
+		plane = NULL;
+		dispatch(e, option);
+	}
 }

 void		set_cylinder(t_env *e)
 {
-	ft_putstr("Cool cylinder");
+	static t_object		*cylinder;
+	char				*option;
+	char				*option_arg;
+
+	if (!cylinder)
+		cylinder = (t_object *)semalloc(sizeof(t_object));
+	cylinder->type = CYLINDER;
+	e->nbline++;
+	if (get_next_line(e->fd, &option) == 1 && option[0] == ' ')
+	{
+		option = trim_option(e, option, &option_arg);
+		if (!ft_strcmp("origin", option))
+			cylinder->origin = set_vector(e, option_arg);
+		else if (!ft_strcmp("radius", option))
+			cylinder->radius = ft_atoi(option_arg);
+		else if (!ft_strcmp("color", option))
+			cylinder->color = set_color(e, option_arg);
+		else
+			unknown_option(option, e->nbline, "sphere");
+		free(option);
+		set_cylinder(e);
+	}
+	else
+	{
+		set_last_obj(e, cylinder);
+		cylinder = NULL;
+		dispatch(e, option);
+	}
 }

 void		set_cone(t_env *e)
 {
-	ft_putstr("Cool cone");
+	static t_object		*cone;
+	char				*option;
+	char				*option_arg;
+
+	if (!cone)
+		cone = (t_object *)semalloc(sizeof(t_object));
+	cone->type = CONE;
+	e->nbline++;
+	if (get_next_line(e->fd, &option) == 1 && option[0] == ' ')
+	{
+		option = trim_option(e, option, &option_arg);
+		if (!ft_strcmp("origin", option))
+			cone->origin = set_vector(e, option_arg);
+		else if (!ft_strcmp("radius", option))
+			cone->radius = ft_atoi(option_arg);
+		else if (!ft_strcmp("color", option))
+			cone->color = set_color(e, option_arg);
+		else
+			unknown_option(option, e->nbline, "cone");
+		free(option);
+		set_cone(e);
+	}
+	else
+	{
+		set_last_obj(e, cone);
+		cone = NULL;
+		dispatch(e, option);
+	}
 }


More renaming.

More renaming.

--- pdcurses/color.c
+++ pdcurses/color.c
@@ -25,9 +25,7 @@
 #undef PAIR_NUMBER
 #undef has_colors

-static void PDC_init_pair(short, short, short);
-
-RCSID("$Id: color.c,v 1.54 2006/08/20 21:48:36 wmcbrine Exp $");
+RCSID("$Id: color.c,v 1.55 2006/08/21 17:31:44 wmcbrine Exp $");

 /*man-start**************************************************************

@@ -145,112 +143,7 @@
 	return OK;
 }

-int init_pair(short colorpair, short foreground, short background)
-{
-	PDC_LOG(("init_pair() - called: colorpair %d fore %d back %d\n",
-		colorpair, foreground, background));
-
-	if (!colorstarted || colorpair >= COLOR_PAIRS || colorpair < 1)
-		return ERR;
-
-	/* To allow the PDC_PRESERVE_SCREEN option to work, we only
-	   reset curscr if this call to init_pair() alters a color pair
-	   created by the user. */
-
-	if (colorset[colorpair])
-	{
-	    short oldforeground, oldbackground;
-
-	    pair_content(colorpair, &oldforeground, &oldbackground);
-
-	    if (oldforeground != foreground || oldbackground != background)
-		curscr->_clear = TRUE;
-	}
-
-	PDC_init_pair(colorpair, foreground, background);
-
-	colorset[colorpair] = TRUE;
-
-	return OK;
-}
-
-bool has_colors(void)
-{
-	PDC_LOG(("has_colors() - called\n"));
-
-	return !(SP->mono);
-}
-
-int init_color(short color, short red, short green, short blue)
-{
-	PDC_LOG(("init_color() - called\n"));
-
-	return ERR;
-}
-
-int color_content(short color, short *red, short *green, short *blue)
-{
-	PDC_LOG(("color_content() - called\n"));
-
-	/* A crude implementation. Does not account for intensity.
-	   ncurses uses 680 for non-A_BOLD, so let's copy that. - WJM3 	*/
-
-	if ((color >= COLORS || color < 0) || (!red || !green || !blue))
-		return ERR;
-
-	*red = (color & COLOR_RED) ? 680 : 0;
-	*green = (color & COLOR_GREEN) ? 680 : 0;
-	*blue = (color & COLOR_BLUE) ? 680 : 0;
-
-	return OK;
-}
-
-bool can_change_color(void)
-{
-	PDC_LOG(("can_change_color() - called\n"));
-
-	return FALSE;
-}
-
-int pair_content(short colorpair, short *foreground, short *background)
-{
-	PDC_LOG(("pair_content() - called\n"));
-
-	if ((colorpair >= COLOR_PAIRS || colorpair < 1) ||
-	    (!foreground || !background))
-		return ERR;
-
-	*foreground = (short)(pdc_atrtab[colorpair * PDC_OFFSET] & 0x0F);
-	*background = (short)((pdc_atrtab[colorpair * PDC_OFFSET] & 0xF0) >> 4);
-
-	return OK;
-}
-
-int PDC_set_line_color(short color)
-{
-	if (color >= COLORS || color < 0)
-		return ERR;
-
-	SP->line_color = color;
-
-	return OK;
-}
-
-void PDC_init_atrtab(void)
-{
-	int i;
-
-	if (!SP->orig_attr)
-	{
-		SP->orig_fore = COLOR_WHITE;
-		SP->orig_back = COLOR_BLACK;
-	}
-
-	for (i = 0; i < PDC_COLOR_PAIRS; i++)
-		PDC_init_pair(i, SP->orig_fore, SP->orig_back);
-}
-
-static void PDC_init_pair(short pairnum, short fg, short bg)
+static void _init_pair_core(short pairnum, short fg, short bg)
 {
 	unsigned char att, temp_bg;
 	chtype i;
@@ -276,3 +169,108 @@
 		pdc_atrtab[(pairnum * PDC_OFFSET) + i] = att;
 	}
 }
+
+int init_pair(short colorpair, short foreground, short background)
+{
+	PDC_LOG(("init_pair() - called: colorpair %d fore %d back %d\n",
+		colorpair, foreground, background));
+
+	if (!colorstarted || colorpair >= COLOR_PAIRS || colorpair < 1)
+		return ERR;
+
+	/* To allow the PDC_PRESERVE_SCREEN option to work, we only
+	   reset curscr if this call to init_pair() alters a color pair
+	   created by the user. */
+
+	if (colorset[colorpair])
+	{
+	    short oldforeground, oldbackground;
+
+	    pair_content(colorpair, &oldforeground, &oldbackground);
+
+	    if (oldforeground != foreground || oldbackground != background)
+		curscr->_clear = TRUE;
+	}
+
+	_init_pair_core(colorpair, foreground, background);
+
+	colorset[colorpair] = TRUE;
+
+	return OK;
+}
+
+bool has_colors(void)
+{
+	PDC_LOG(("has_colors() - called\n"));
+
+	return !(SP->mono);
+}
+
+int init_color(short color, short red, short green, short blue)
+{
+	PDC_LOG(("init_color() - called\n"));
+
+	return ERR;
+}
+
+int color_content(short color, short *red, short *green, short *blue)
+{
+	PDC_LOG(("color_content() - called\n"));
+
+	/* A crude implementation. Does not account for intensity.
+	   ncurses uses 680 for non-A_BOLD, so let's copy that. - WJM3 	*/
+
+	if ((color >= COLORS || color < 0) || (!red || !green || !blue))
+		return ERR;
+
+	*red = (color & COLOR_RED) ? 680 : 0;
+	*green = (color & COLOR_GREEN) ? 680 : 0;
+	*blue = (color & COLOR_BLUE) ? 680 : 0;
+
+	return OK;
+}
+
+bool can_change_color(void)
+{
+	PDC_LOG(("can_change_color() - called\n"));
+
+	return FALSE;
+}
+
+int pair_content(short colorpair, short *foreground, short *background)
+{
+	PDC_LOG(("pair_content() - called\n"));
+
+	if ((colorpair >= COLOR_PAIRS || colorpair < 1) ||
+	    (!foreground || !background))
+		return ERR;
+
+	*foreground = (short)(pdc_atrtab[colorpair * PDC_OFFSET] & 0x0F);
+	*background = (short)((pdc_atrtab[colorpair * PDC_OFFSET] & 0xF0) >> 4);
+
+	return OK;
+}
+
+int PDC_set_line_color(short color)
+{
+	if (color >= COLORS || color < 0)
+		return ERR;
+
+	SP->line_color = color;
+
+	return OK;
+}
+
+void PDC_init_atrtab(void)
+{
+	int i;
+
+	if (!SP->orig_attr)
+	{
+		SP->orig_fore = COLOR_WHITE;
+		SP->orig_back = COLOR_BLACK;
+	}
+
+	for (i = 0; i < PDC_COLOR_PAIRS; i++)
+		_init_pair_core(i, SP->orig_fore, SP->orig_back);
+}


In wgetch(), delay after a failed call to PDC_check_bios_key(), but recycle immediately after a bad result from PDC_get_bios_key(). This means no waiting when there are keys in the buffer that just aren't desired; it fixes the incredibly slow pasting I got with Unicode text in Win32.

--- pdcurses/getch.c
+++ pdcurses/getch.c
@@ -16,7 +16,7 @@
 #define _INBUFSIZ	512	/* size of terminal input buffer */
 #define NUNGETCH	256	/* max # chars to ungetch() */

-RCSID("$Id: getch.c,v 1.57 2006/11/15 16:26:45 wmcbrine Exp $");
+RCSID("$Id: getch.c,v 1.58 2006/11/24 05:05:40 wmcbrine Exp $");

 static int c_pindex = 0;	/* putter index */
 static int c_gindex = 1;	/* getter index */
@@ -268,27 +268,9 @@
 	for (;;)			/* loop for any buffering */
 	{
 		if (!PDC_check_bios_key())
-			key = -1;
-		else
 		{
-			key = PDC_get_bios_key();
-
-			/* Filter special keys if not in keypad mode */
-
-			if (SP->key_code && !win->_use_keypad)
-				key = -1;
-		}
-
-		/* filter mouse events; translate mouse clicks in the
-		   slk area to function keys */
-
-		if (key == KEY_MOUSE && SP->key_code)
-			key = _mouse_key(win);
-
-		/* handle timeout() and halfdelay() */
-
-		if (key == -1)
-		{
+			/* handle timeout() and halfdelay() */
+
 			if (SP->delaytenths || win->_delayms)
 			{
 				if (!waitcount)
@@ -303,6 +285,26 @@
 			napms(50);	/* sleep for 1/20th second */
 			continue;
 		}
+		else
+		{
+			key = PDC_get_bios_key();
+
+			/* Filter special keys if not in keypad mode */
+
+			if (SP->key_code && !win->_use_keypad)
+				key = -1;
+		}
+
+		/* filter mouse events; translate mouse clicks in the
+		   slk area to function keys */
+
+		if (key == KEY_MOUSE && SP->key_code)
+			key = _mouse_key(win);
+
+		/* unwanted results from PDC_get_bios_key()? */
+
+		if (key == -1)
+			continue;

 		/* translate CR */


Removed assertions

Removed assertions

--- src/structures/CBObject/CBByteArray/CBByteArray.c
+++ src/structures/CBObject/CBByteArray/CBByteArray.c
@@ -23,6 +23,7 @@
 //  SEE HEADER FILE FOR DOCUMENTATION

 #include "CBByteArray.h"
+#include <assert.h>

 //  Constructor

@@ -209,6 +210,7 @@
 	memmove(self->sharedData->data + self->offset + writeOffset,source->sharedData->data + source->offset,source->length);
 }
 void CBByteArrayCopySubByteArray(CBByteArray * self,uint32_t writeOffset,CBByteArray * source,uint32_t readOffset,uint32_t length){
+	assert(length);
 	memmove(self->sharedData->data + self->offset + writeOffset,source->sharedData->data + source->offset + readOffset,length);
 }
 bool CBByteArrayEquals(CBByteArray * self,CBByteArray * second){


my heart is a chocolate cornet

my heart is a chocolate cornet

--- Common/Input.c
+++ Common/Input.c
@@ -381,6 +381,7 @@
 	char *outFile;
 	char *path;

+	errorCase(isFactoryDirDisabled());
 	errorCase(!existFile(WDROP_EXE_FILE)); // OR}h݊mF

 	funcMtx = mutexLock("{5396f16e-d695-4d3d-81a1-5b751d0d2068}");


[X86] Add support for avx512bf16 for __builtin_cpu_supports and compiler-rt's cpu indicator.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@370915 91177308-0d34-0410-b5e6-96231b3b80d8

--- test/CodeGen/target-builtin-noerror.c
+++ test/CodeGen/target-builtin-noerror.c
@@ -80,6 +80,7 @@
   (void)__builtin_cpu_supports("vpclmulqdq");
   (void)__builtin_cpu_supports("avx512vnni");
   (void)__builtin_cpu_supports("avx512bitalg");
+  (void)__builtin_cpu_supports("avx512bf16");
 }

 void verifycpustrings() {


Fixed window behavior

Fixed window behavior

--- Core/display.c
+++ Core/display.c
@@ -366,6 +366,10 @@
                 }
             }
             ly_for_comparison = gb->io_registers[GB_IO_LY] = 0;
+
+            /* Reset window rendering state */
+            gb->effective_window_enabled = false;
+            gb->effective_window_y = 0xFF;
             display_vblank(gb);
         }


demux: h265: alias hevc with h265

demux: h265: alias hevc with h265

--- modules/demux/mpeg/h26x.c
+++ modules/demux/mpeg/h26x.c
@@ -64,7 +64,7 @@
         set_capability( "demux", 6 )
         add_float( "hevc-fps", 0.0, FPS_TEXT, FPS_LONGTEXT, true )
         set_callbacks( OpenHEVC, Close )
-        add_shortcut( "hevc" )
+        add_shortcut( "hevc", "h265" )

 vlc_module_end ()


Fixed resize bug when changing main scene in fullscreen mode

git-svn-id: 33bf1455041ebe448dbaea643fd5b4b7ce02239d@3621 63c20433-aa62-49bd-875c-5a186b69a8fb

--- modules/dx_hw/dx_window.c
+++ modules/dx_hw/dx_window.c
@@ -1015,14 +1015,14 @@
 	/*if scene resize resize window*/
 	case GF_EVENT_SIZE:
 		if (ctx->owns_hwnd) {
-			if (ctx->windowless)
-				SetWindowPos(ctx->os_hwnd, NULL, 0, 0, evt->size.width, evt->size.height, SWP_NOZORDER | SWP_NOMOVE | SWP_ASYNCWINDOWPOS);
-			else
-				SetWindowPos(ctx->os_hwnd, NULL, 0, 0, evt->size.width + ctx->off_w, evt->size.height + ctx->off_h, SWP_NOZORDER | SWP_NOMOVE | SWP_ASYNCWINDOWPOS);
-
 			if (ctx->fullscreen) {
 				ctx->store_width = evt->size.width;
 				ctx->store_height = evt->size.height;
+			} else {
+				if (ctx->windowless)
+					SetWindowPos(ctx->os_hwnd, NULL, 0, 0, evt->size.width, evt->size.height, SWP_NOZORDER | SWP_NOMOVE | SWP_ASYNCWINDOWPOS);
+				else
+					SetWindowPos(ctx->os_hwnd, NULL, 0, 0, evt->size.width + ctx->off_w, evt->size.height + ctx->off_h, SWP_NOZORDER | SWP_NOMOVE | SWP_ASYNCWINDOWPOS);
 			}
 		}
 		break;


increase min power

increase min power

--- PropellerCodeForArloBot/ROSInterfaceForArloBotWithDHB10.c
+++ PropellerCodeForArloBot/ROSInterfaceForArloBotWithDHB10.c
@@ -217,7 +217,7 @@
 ignoreIRSensors = 0,
 pluggedIn = 0;

-static volatile int controlByPower = 1, minPowerValue = 10;
+static volatile int controlByPower = 1, minPowerValue = 25;

 void safetyOverride(void *par); // Use a cog to squelch incoming commands and perform safety procedures like halting, backing off, avoiding cliffs, calling for help, etc.
 // This can use proximity sensors to detect obstacles (including people) and cliffs


Check token is NULL

Check token is NULL

Keep the variables as default if token is NULL

--- PropellerCodeForArloBot/ROSInterfaceForArloBotWithDHB10.c
+++ PropellerCodeForArloBot/ROSInterfaceForArloBotWithDHB10.c
@@ -419,12 +419,18 @@
                 char *token;
                 token = strtok(buf, delimiter);
                 token = strtok(NULL, delimiter);
-                char *unconverted;
-                X = strtod(token, &unconverted);
-                token = strtok(NULL, delimiter);
-                Y = strtod(token, &unconverted);
-                token = strtok(NULL, delimiter);
-                Heading = strtod(token, &unconverted);
+                char *unconverted;
+                if (token != NULL) {
+                    X = strtod(token, &unconverted);
+                    token = strtok(NULL, delimiter);
+                }
+                if (token != NULL) {
+                    Y = strtod(token, &unconverted);
+                    token = strtok(NULL, delimiter);
+                }
+                if (token != NULL) {
+                    Heading = strtod(token, &unconverted);
+                }
                 timeoutCounter = 0;
             }
         }


Fabric: Fixing `executeSynchronouslyOnSameThread_CAN_DEADLOCK`

Summary:
In D20551411 we (I) replaced `std::mutex` with `std::recursive_mutex` in `executeSynchronouslyOnSameThread_CAN_DEADLOCK` in order to support synchronous `RuntimeExecutor`. It turned out that the idea was cool but totally incorrect. Quite obviously, double locking recursive mutex on the same thread does nothing, so the whole setup does not work at all.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21328072

fbshipit-source-id: 7f1f81de61c36adb167fe624ada3bd71913bdf7c

--- ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h
+++ ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h
@@ -78,12 +78,10 @@
     std::function<void(jsi::Runtime &runtime)> &&callback) noexcept {
   // Note: We need the third mutex to get back to the main thread before
   // the lambda is finished (because all mutexes are allocated on the stack).
-  // We use `recursive_mutex` here to not deadlock in case if a
-  // `RuntimeExecutor` executes the callback synchronously.

-  std::recursive_mutex mutex1;
-  std::recursive_mutex mutex2;
-  std::recursive_mutex mutex3;
+  std::mutex mutex1;
+  std::mutex mutex2;
+  std::mutex mutex3;

   mutex1.lock();
   mutex2.lock();


Inroduce BoxComponent

Inroduce BoxComponent

Summary:
The goal of this diff is to introduce the scafolding of a BoxComponent. This class will be eventually shared by Android and iOS

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D41205801

fbshipit-source-id: e33e58062aa33e0c8e9a48fd112309a358f0a060

--- ReactAndroid/src/main/jni/react/cxxcomponents/ComponentManager.h
+++ ReactAndroid/src/main/jni/react/cxxcomponents/ComponentManager.h
@@ -21,7 +21,7 @@
       Tag tag,
       Props::Shared initialProps) = 0;

-  virtual std::shared_ptr<Component> createComponent(Tag tag) = 0;
+  virtual std::unique_ptr<Component> createComponent(Tag tag) = 0;

   virtual ~ComponentManager() = default;
 };


Fixed bug in serif default font association

git-svn-id: ab66a9de07fa9d47c5829c82992f5279466c775f@1507 63c20433-aa62-49bd-875c-5a186b69a8fb

--- modules/ft_font/ft_font.c
+++ modules/ft_font/ft_font.c
@@ -127,12 +127,19 @@

 					if (store) ftpriv->font_sans = strdup(face->family_name);
 				}
-				if (!store && ftpriv->font_serif) {
-					if (!strnicmp(face->family_name, "Times New Roman", 15)) store = 1;
+
+				if (!strnicmp(face->family_name, "Times New Roman", 15)) {
+					if (ftpriv->font_serif) free(ftpriv->font_serif);
+					ftpriv->font_serif = strdup(face->family_name);
+				}
+				else if (!store && !ftpriv->font_serif) {
+					if (!strnicmp(face->family_name, "Times New Roman", 15))
+						store = 1;
 					else if (strstr(szfont, "sans") || strstr(szfont, "fixed")) store = 0;
 					else if (strstr(szfont, "serif")) store = 1;

-					if (store) ftpriv->font_sans = face->family_name;
+					if (store)
+						ftpriv->font_serif = strdup(face->family_name);
 				}
 			}
 			free(szfont);


Allowed GPAC object to be shared among script contexts with old SpiderMonkey

--- modules/gpac_js/gpac_js.c
+++ modules/gpac_js/gpac_js.c
@@ -839,10 +839,14 @@
 		}
 		return;
 	}
+
+	/*FIXME - this was possible in previous version of SpiderMonkey, don't know how to fix that for new ones*/
+#if (JS_VERSION>=185)
 	if (gjs->nb_loaded) {
 		gjs->nb_loaded++;
 		return;
 	}
+#endif
 	gjs->nb_loaded++;

 	if (!scene) return;


PhysicallyBased_Forward_Common - emissiveColor가 제대로 작동되게 함, 코드 정리

--- SOCEngine/SOCEngine/ShaderCodes/PhysicallyBased_Forward_Common.h
+++ SOCEngine/SOCEngine/ShaderCodes/PhysicallyBased_Forward_Common.h
@@ -15,23 +15,20 @@

 float4 Lighting(float3 normal, float3 vtxWorldPos, float2 SVPosition, float2 uv)
 {
-	float4 diffuseTex			= diffuseMap.Sample(defaultSampler, uv);
-
-	float metallic				= GetMaterialMetallic();
-	float roughness				= GetMaterialRoughness();
+	float metallic				= GetMetallic(defaultSampler, uv);
+	float roughness				= GetRoughness(defaultSampler, uv);
 	float specularity			= GetMaterialSpecularity();

-	float3 emissionColor		= GetMaterialEmissiveColor().rgb;
-	float3 mainColor			= GetMaterialMainColor().rgb;
-	float3 diffuseColor			= lerp(mainColor, diffuseTex.rgb * mainColor, HasDiffuseMap());
+	float3 emissiveColor		= GetEmissiveColor(defaultSampler, uv);
+	float3 albedo				= GetAlbedo(defaultSampler, uv);

 	LightingParams lightParams;

 	lightParams.viewDir			= normalize( tbrParam_cameraWorldPosition - vtxWorldPos );
 	lightParams.normal			= normal;
 	lightParams.roughness		= roughness;
-	lightParams.diffuseColor	= diffuseColor - diffuseColor * metallic;
-	lightParams.specularColor	= lerp(0.08f * specularity.xxx, diffuseColor, metallic);
+	lightParams.diffuseColor	= albedo - albedo * metallic;
+	lightParams.specularColor	= lerp(0.08f * specularity.xxx, albedo, metallic);

 	uint tileIdx				= GetTileIndex(SVPosition);
 	uint startIdx				= tileIdx * tbrParam_maxNumOfPerLightInTile + 1;
@@ -139,16 +136,14 @@
 	float3 back		= (accumulativeBackFaceDiffuse + accumulativeBackFaceSpecular) * TRANSPARENCY_BACK_FACE_WEIGHT;
 	float3 front	= (accumulativeFrontFaceDiffuse + accumulativeFrontFaceSpecular);

-	float3	result = front + back;
-
-	float	diffuseTexAlpha = lerp(1.0f, diffuseTex.a, HasDiffuseMap());
-	float	alpha = diffuseTexAlpha * (1.0f - opacityMap.Sample(defaultSampler, uv).x) * GetMaterialMainColor().a;
+	float3	result	= front + back;
+	float	alpha	= GetAlpha(defaultSampler, uv);
 #else
 	float3	result = accumulativeDiffuse + accumulativeSpecular;
 	float	alpha = 1.0f;
 #endif

-	return float4(result, alpha);
+	return float4(result + emissiveColor, alpha);
 }

 #endif


PhysicallyBased_Forward_Common 에러 수정 #73

--- SOCEngine/SOCEngine/ShaderCodes/PhysicallyBased_Forward_Common.h
+++ SOCEngine/SOCEngine/ShaderCodes/PhysicallyBased_Forward_Common.h
@@ -7,7 +7,7 @@

 #include "PhysicallyBased_Common.h"
 #include "BRDF.h"
-#include "LightCulling_CS.h"
+#include "LightCullingCommonCS.h"

 Buffer<uint> g_perLightIndicesInTile	: register( t13 );
 SamplerState defaultSampler				: register( s0 );


Added HALIDE_OUTPUT_FORWARD_CONST and appropriate usage

Former-commit-id: b2c95162040507997ea3d78df1691d68c56f1e4d

--- src/Generator.h
+++ src/Generator.h
@@ -1668,17 +1668,24 @@
         return get_func_ref().method(std::forward<Args>(args)...);          \
     }

+#define HALIDE_OUTPUT_FORWARD_CONST(method)                                 \
+    template<typename ...Args>                                              \
+    inline auto method(Args&&... args) const ->                             \
+        decltype(std::declval<Func>().method(std::forward<Args>(args)...)) {\
+        return get_func_ref().method(std::forward<Args>(args)...);          \
+    }
+
     /** Forward schedule-related methods to the underlying Func. */
     // @{
     HALIDE_OUTPUT_FORWARD(align_bounds)
     HALIDE_OUTPUT_FORWARD(align_storage)
-    HALIDE_OUTPUT_FORWARD(args)
+    HALIDE_OUTPUT_FORWARD_CONST(args)
     HALIDE_OUTPUT_FORWARD(bound)
     HALIDE_OUTPUT_FORWARD(bound_extent)
     HALIDE_OUTPUT_FORWARD(compute_at)
     HALIDE_OUTPUT_FORWARD(compute_inline)
     HALIDE_OUTPUT_FORWARD(compute_root)
-    HALIDE_OUTPUT_FORWARD(defined)
+    HALIDE_OUTPUT_FORWARD_CONST(defined)
     HALIDE_OUTPUT_FORWARD(fold_storage)
     HALIDE_OUTPUT_FORWARD(fuse)
     HALIDE_OUTPUT_FORWARD(glsl)
@@ -1687,19 +1694,19 @@
     HALIDE_OUTPUT_FORWARD(gpu_single_thread)
     HALIDE_OUTPUT_FORWARD(gpu_threads)
     HALIDE_OUTPUT_FORWARD(gpu_tile)
-    HALIDE_OUTPUT_FORWARD(has_update_definition)
+    HALIDE_OUTPUT_FORWARD_CONST(has_update_definition)
     HALIDE_OUTPUT_FORWARD(hexagon)
     HALIDE_OUTPUT_FORWARD(in)
     HALIDE_OUTPUT_FORWARD(memoize)
-    HALIDE_OUTPUT_FORWARD(num_update_definitions)
-    HALIDE_OUTPUT_FORWARD(output_types)
-    HALIDE_OUTPUT_FORWARD(outputs)
+    HALIDE_OUTPUT_FORWARD_CONST(num_update_definitions)
+    HALIDE_OUTPUT_FORWARD_CONST(output_types)
+    HALIDE_OUTPUT_FORWARD_CONST(outputs)
     HALIDE_OUTPUT_FORWARD(parallel)
     HALIDE_OUTPUT_FORWARD(prefetch)
     HALIDE_OUTPUT_FORWARD(rename)
     HALIDE_OUTPUT_FORWARD(reorder)
     HALIDE_OUTPUT_FORWARD(reorder_storage)
-    HALIDE_OUTPUT_FORWARD(rvars)
+    HALIDE_OUTPUT_FORWARD_CONST(rvars)
     HALIDE_OUTPUT_FORWARD(serial)
     HALIDE_OUTPUT_FORWARD(shader)
     HALIDE_OUTPUT_FORWARD(specialize)
@@ -1709,11 +1716,11 @@
     HALIDE_OUTPUT_FORWARD(tile)
     HALIDE_OUTPUT_FORWARD(unroll)
     HALIDE_OUTPUT_FORWARD(update)
-    HALIDE_OUTPUT_FORWARD(update_args)
-    HALIDE_OUTPUT_FORWARD(update_value)
-    HALIDE_OUTPUT_FORWARD(update_values)
-    HALIDE_OUTPUT_FORWARD(value)
-    HALIDE_OUTPUT_FORWARD(values)
+    HALIDE_OUTPUT_FORWARD_CONST(update_args)
+    HALIDE_OUTPUT_FORWARD_CONST(update_value)
+    HALIDE_OUTPUT_FORWARD_CONST(update_values)
+    HALIDE_OUTPUT_FORWARD_CONST(value)
+    HALIDE_OUTPUT_FORWARD_CONST(values)
     HALIDE_OUTPUT_FORWARD(vectorize)
     // }@

@@ -1746,6 +1753,12 @@
     EXPORT void check_value_writable() const override;

     NO_INLINE Func &get_func_ref() {
+        internal_assert(kind() != IOKind::Scalar);
+        internal_assert(funcs_.size() == array_size() && exprs_.empty());
+        return funcs_[0];
+    }
+
+    NO_INLINE const Func &get_func_ref() const {
         internal_assert(kind() != IOKind::Scalar);
         internal_assert(funcs_.size() == array_size() && exprs_.empty());
         return funcs_[0];


bugfix

bugfix


some progress on euler

some progress on euler

--- csim2/StrictlyProperBlock.c
+++ csim2/StrictlyProperBlock.c
@@ -8,26 +8,41 @@
 	struct StrictlyProperBlock const * const block,
 	double const ti,
 	double const dt,
-	double const tf
+	double const tf,
+	InputFunction const uf,
+	size_t const xi,
+	double * const Xi
 )
 {
+	assert(xi == block->numStates);
 	OutputFunction const h = block->h;
 	PhysicsFunction const f = block->f;
-	size_t const xi = block->numStates;
+	//size_t const xi = block->numStates;
 	size_t const yi = block->numOutputs;
 	size_t const ui = block->numInputs;
 	void * const storage = block->storage;
+	size_t const num_steps = (size_t const)floor((tf - ti) / dt) + 1;
+	double t;

-	size_t const num_steps = (size_t const)floor((tf - ti) / dt) + 1;
+	double * const Y = malloc(num_steps * yi * sizeof(double));
+	assert(Y != NULL);
+	double * const U = malloc(ui * sizeof(double));
+	assert(U != NULL);
+	double * const dX = malloc(xi * sizeof(double));
+	assert(dX != NULL);

 	for (size_t i = 0; i < num_steps; i++)
 	{
-		double const t = ti + i*dt;
-		//h(yi, &Y[i*yi], t, xi, Xi, storage);
-		//f(xi, dX, t, xi, Xi, ui, U, storage);
-		//for (size_t j = 0; j < xi; j++)
-			//Xi[j] += dX[j] * dt;
+		t = ti + i*dt;
+		h(yi, &Y[i*yi], t, xi, Xi, storage);
+		uf(ui, U, t);
+		f(xi, dX, t, xi, Xi, ui, U, storage);
+		for (size_t j = 0; j < xi; j++)
+			Xi[j] += dX[j] * dt;
 	}
+	free(Y);
+	free(U);
+	free(dX);
 }

 void rk4


Remove unused, nonportable header file (stropts.h).

git-svn-id: 769d22dfa2d22aad706b9a451492fb87c0735f19@358 08b38cba-cd3b-11de-854e-f91c5b6e4272

--- modules/gadgeteer/gadget/Devices/Immersion/driveunx.c
+++ modules/gadgeteer/gadget/Devices/Immersion/driveunx.c
@@ -21,7 +21,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/time.h>
-#include <stropts.h>
 #include <Input/ibox/driveunx.h>


Reverted pointless change.

Reverted pointless change.

Former-commit-id: 98a5bd6f0e282224a17f96606c42ac7f793d0450

--- src/IRVisitor.h
+++ src/IRVisitor.h
@@ -126,7 +126,7 @@
     // @}

     /** The nodes visited so far */
-    std::set<const void *> visited;
+    std::set<const IRNode *> visited;

 public:


Atualização da InputData

Atualização da InputData

--- src/InputData.h
+++ src/InputData.h
@@ -20,6 +20,13 @@
         static std::vector<Base*>* getBases();
         static std::vector<Customer*>*  getCustomers();

+        Driver* findDriver(int id);
+        Trailer* findTrailer(int id);
+        Location* findLocation(int id);
+
+        double getDistance(int origin, int destination);
+        int getTime(int origin, int destination);
+
         virtual ~InputData();
     protected:
     private:
@@ -30,7 +37,10 @@
         std::vector<Customer*> customers_;
         double** distance_;
         int** time_;
-        int** windowSize_;
+        //int** windowSize_;
+
+        //find de cada um *
+        //acesso e criação de matriz

         static InputData* instance;
 };


Fix problems compiling the socket plugin for pre-WinXP.
Patch by: Edgar Velazquez-Armendariz
Review by: c42f

git-svn-id: c3edda122e248ef33995da003806c930f62b9468@1615 31904243-a364-42ac-a3db-9305396518ba

--- src/socket.imageio/socket_pvt.h
+++ src/socket.imageio/socket_pvt.h
@@ -40,6 +40,14 @@
 #include "imageio.h"

 #include <map>
+
+// The boost::asio library uses functionality only available since Windows XP,
+// thus _WIN32_WINNT must be set to _WIN32_WINNT_WINXP (0x0501) or greater.
+// If _WIN32_WINNT is not defined before including the asio headers, they issue
+// a message warning that _WIN32_WINNT was explicitly set to _WIN32_WINNT_WINXP.
+#if defined(_WIN32) && !defined(_WIN32_WINNT)
+#  define _WIN32_WINNT 0x0501
+#endif

 #include <boost/asio.hpp>
 #include <boost/shared_ptr.hpp>


piegen: fix build on 64-bit ubuntu

piegen: fix build on 64-bit ubuntu

The error I got was:

  CC       pie/piegen/elf-x86-64.o
In file included from pie/piegen/elf-x86-32.c:16:0:
pie/piegen/elf.c: In function ‘handle_elf_x86_32’:
pie/piegen/elf.c:476:3: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘Elf32_Word’ [-Werror=format=]
   pr_debug("Copying section '%s'\n" \
   ^

Signed-off-by: Tycho Andersen <10c18fcb898ee6b17d6575d444b125d10b3f4d6a@canonical.com>
Signed-off-by: Pavel Emelyanov <c9a32589e048e044184536f7ac71ef92fe82df3e@parallels.com>

--- pie/piegen/elf.c
+++ pie/piegen/elf.c
@@ -476,7 +476,7 @@
 		pr_debug("Copying section '%s'\n" \
 			 "\tstart:0x%lx (gap:0x%lx) size:0x%lx\n",
 			 &secstrings[sh->sh_name], (unsigned long) sh->sh_addr,
-			 (unsigned long)(sh->sh_addr - k), sh->sh_size);
+			 (unsigned long)(sh->sh_addr - k), (unsigned long) sh->sh_size);

 		/* write 0 in the gap between the 2 sections */
 		for (;k < sh->sh_addr; k++) {


Remove "(EXPERIMENTAL)" designation for Jacobian bias calculations since these have now been tested.

--- Simbody/include/simbody/internal/SimbodyMatterSubsystem.h
+++ Simbody/include/simbody/internal/SimbodyMatterSubsystem.h
@@ -516,8 +516,7 @@
                                const Vector&        u,
                                Vector_<SpatialVec>& Ju) const;

-/** (EXPERIMENTAL)
-Calculate the acceleration bias term for the system Jacobian, that is, the
+/** Calculate the acceleration bias term for the system Jacobian, that is, the
 part of the acceleration that is due only to velocities. This term is also
 known as the Coriolis acceleration, and it is returned here as a spatial
 acceleration of each body frame in Ground.
@@ -673,8 +672,7 @@
                                const Vector&        u) const;

-/** (EXPERIMENTAL)
-Calculate the acceleration bias term for a station Jacobian, that is, the
+/** Calculate the acceleration bias term for a station Jacobian, that is, the
 part of the station's acceleration that is due only to velocities. This term
 is also known as the Coriolis acceleration, and it is returned here as a linear
 acceleration of the station in Ground.
@@ -789,8 +787,7 @@
                                     const Vector&        u) const;

-/** (EXPERIMENTAL)
-Calculate the acceleration bias term for a frame Jacobian, that is, the
+/** Calculate the acceleration bias term for a frame Jacobian, that is, the
 part of the frame's acceleration that is due only to velocities. This term
 is also known as the Coriolis acceleration, and it is returned here as a spatial
 acceleration of the frame in Ground.


Fix Linux64 compilation with another format warning->error.

git-svn-id: 88467cb1fb04b8a755be7e1ee1026be4190196ef@2405 3a8e244f-b0f2-452b-bcba-4c88e055c3ca

--- runtime/src/chplmem.c
+++ runtime/src/chplmem.c
@@ -142,7 +142,7 @@
     fprintf(stdout, "%-*u%-*u%-*u0x%-*x%-s\n",
             numberWidth, (unsigned)memEntry->size,
             numberWidth, (unsigned)memEntry->number,
-            numberWidth, chunk,
+            numberWidth, (unsigned)chunk,
             memAllocWidth, (unsigned)(intptr_t)memEntry->memAlloc,
             memEntry->description);
   }


Convert hasValue to static inline

Convert hasValue to static inline

--- Source/Library/Collection/HCIsDictionaryContainingValue.h
+++ Source/Library/Collection/HCIsDictionaryContainingValue.h
@@ -18,9 +18,8 @@

 #ifndef HC_DISABLE_SHORT_SYNTAX
 /*!
- * @abstract hasValue(valueMatcher) -
- * Creates a matcher for NSDictionaries that matches when the examined dictionary contains at least
- * value that satisfies the specified matcher.
+ * @abstract Creates a matcher for NSDictionaries that matches when the examined dictionary contains
+ * at least value that satisfies the specified matcher.
  * @param valueMatcher The matcher to satisfy for the value, or an expected value for equalTo matching.
  * @discussion This matcher works on any collection that has an -allValues method.
  *
@@ -29,11 +28,14 @@
  *
  * Examples

  *
assertThat(myDictionary, hasValue(equalTo(\@"bar")))

- *
assertThat(myDictionary, hasValue(\@"bar"))

+ *
assertThat(myDictionary, hasValue(\@"bar"))

  *
  * Name Clash

  * In the event of a name clash, #define HC_DISABLE_SHORT_SYNTAX and use the synonym
  * HC_hasValue instead.
  */
-#define hasValue HC_hasValue
+static inline id hasValue(id valueMatcher)
+{
+    return HC_hasValue(valueMatcher);
+}
 #endif


loader: clear calculation in boot_copy_region()

Introduced mediate variable for express data chunk offset
from the beginning of the region.

Signed-off-by: Andrzej Puzdrowski <0222c24e1773dd88269ed0e559909ec9bea3604a@nordicsemi.no>

--- boot/bootutil/src/loader.c
+++ boot/bootutil/src/loader.c
@@ -950,14 +950,14 @@
             }
 #endif
             if (IS_ENCRYPTED(hdr)) {
-                if (off + bytes_copied < hdr->ih_hdr_size) {
+                uint32_t abs_off = off + bytes_copied;
+                if (abs_off < hdr->ih_hdr_size) {
                     /* do not decrypt header */
-                    if (off + bytes_copied + chunk_sz > hdr->ih_hdr_size) {
+                    if (abs_off + chunk_sz > hdr->ih_hdr_size) {
                         /* The lower part of the chunk contains header data */
                         blk_off = 0;
-                        blk_sz = chunk_sz - (hdr->ih_hdr_size - off -
-                                 bytes_copied);
-                        idx = hdr->ih_hdr_size  - off - bytes_copied;
+                        blk_sz = chunk_sz - (hdr->ih_hdr_size - abs_off);
+                        idx = hdr->ih_hdr_size  - abs_off;
                     } else {
                         /* The chunk contains exclusively header data */
                         blk_sz = 0; /* nothing to decrypt */
@@ -965,22 +965,22 @@
                 } else {
                     idx = 0;
                     blk_sz = chunk_sz;
-                    blk_off = ((off + bytes_copied) - hdr->ih_hdr_size) & 0xf;
+                    blk_off = (abs_off - hdr->ih_hdr_size) & 0xf;
                 }

                 if (blk_sz > 0)
                 {
                     tlv_off = BOOT_TLV_OFF(hdr);
-                    if (off + bytes_copied + chunk_sz > tlv_off) {
+                    if (abs_off + chunk_sz > tlv_off) {
                         /* do not decrypt TLVs */
-                        if (off + bytes_copied >= tlv_off) {
+                        if (abs_off >= tlv_off) {
                             blk_sz = 0;
                         } else {
-                            blk_sz = tlv_off - (off + bytes_copied);
+                            blk_sz = tlv_off - abs_off;
                         }
                     }
                     boot_encrypt(BOOT_CURR_ENC(state), image_index, fap_src,
-                            (off + bytes_copied + idx) - hdr->ih_hdr_size, blk_sz,
+                            (abs_off + idx) - hdr->ih_hdr_size, blk_sz,
                             blk_off, &buf[idx]);
                 }
             }


adjust gen23

adjust gen23

--- Engine/fgens.c
+++ Engine/fgens.c
@@ -1316,8 +1316,8 @@
     /* Read the next charcater; suppress multiple space and comments to a
        single space */
     int c;
+ top:
     c = getc(f);
- top:
     if (feof(f)) return NAN; /* Hope value is ignored */
     if (isdigit(c) || c=='e' || c=='E' || c=='+' || c=='-' || c=='.') {
       double d;                           /* A number starts */
@@ -1334,7 +1334,7 @@
       }
       return (MYFLT)d;
     }
-    while (isspace(c)) c = getc(f);       /* Whitespace */
+    while (isspace(c) || c == ',') c = getc(f);       /* Whitespace */
     if (c==';' || c=='#' || c=='<') {     /* Comment and tag*/
       while ((c = getc(f)) != '\n');
     }


Remove some of ACPICA's x32 support

Remove some of ACPICA's x32 support

To actually work properly in x32, it would need to manage mappings of
physical memory into the lower 4GB. Let's just require that you build it
in 64-bit mode...

--- cuser/acpica/acenv_header.h
+++ cuser/acpica/acenv_header.h
@@ -18,7 +18,7 @@
 #define ACPI_GET_FUNCTION_NAME ""
 #endif

-static const uintptr_t ACPI_PHYS_BASE = 0x1000000;
+static const uint64_t ACPI_PHYS_BASE = 0x100000000;

 #define AcpiOsPrintf printf
 #define AcpiOsVprintf vprintf


The IsEmpty() method on CBlockOptionsMap is backwards. It returns true only if the map is not empty.

--- Sources_Common/Application/Preferences/CBlockOptionsMap.h
+++ Sources_Common/Application/Preferences/CBlockOptionsMap.h
@@ -35,7 +35,7 @@
 	virtual bool ReadMap(void) = 0;
 	virtual bool WriteMap(bool verify) = 0;
 	virtual bool IsEmpty() const
-		{ return mMap.size(); }
+		{ return mMap.size() == 0; }
 	virtual void DeleteMap(void) = 0;

 	// Look for values under a key


ACPI / scan: fix typo in comments of acpi_bus_unregister_driver()

"APIC" should be "ACPI" here.

Signed-off-by: Hanjun Guo <95c4dbadfa6003adc188d9bdfe4b6c123adc8dc4@linaro.org>
Signed-off-by: Rafael J. Wysocki <27ffc44a8ec6a212fba98cfc3246c6ce8ab131e0@intel.com>

--- drivers/acpi/scan.c
+++ drivers/acpi/scan.c
@@ -1121,7 +1121,7 @@
 EXPORT_SYMBOL(acpi_bus_register_driver);

 /**
- * acpi_bus_unregister_driver - unregisters a driver with the APIC bus
+ * acpi_bus_unregister_driver - unregisters a driver with the ACPI bus
  * @driver: driver to unregister
  *
  * Unregisters a driver with the ACPI bus.  Searches the namespace for all


ACPI: use PNPID:instance_no as bus_id of ACPI device

Previously we used the device name in the DSDT, but would
crash upon encountering a duplicate. Also, exposing the
DSDT device name to the user in a patch isn't a good idea,
because it is arbitrary.

After some discussion, we finally decided to use
"PNPID:instance_no" as the bus_id of ACPI devices.

Two attributes for each device are added at the same time,
the full pathname in ACPI namespace and hardware_id if it has.

NOTE:	acpi_bus_id_list is used to keep the information of PNPID
	and instance number of the given PNPID. Loop the
	acpi_bus_id_list to find the instance_no of the	same PNPID
	when register a device. If failed, i.e. we don't have a
	node with this PNPID, allocate one and link it to this list.

NOTE:	Now I don't take the memory free work in charge.
	If necessary, I can add a reference count in
	struct acpi_device_bus_id, and check the reference and
	when unregister a device, i.e. memory is freed when
	the reference count of a given PNPID is 0.

Signed-off-by: Li Shaohua <cb3904095a5bc20edc93ba3dfa3e7d27d981b654@intel.com>
Signed-off-by: Len Brown <b060cfa1096cc6e8be83699ddb4ed8a77dd63af5@intel.com>

--- drivers/acpi/scan.c
+++ drivers/acpi/scan.c
@@ -21,9 +21,15 @@
 #define ACPI_BUS_DEVICE_NAME		"System Bus"

 static LIST_HEAD(acpi_device_list);
+static LIST_HEAD(acpi_bus_id_list);
 DEFINE_SPINLOCK(acpi_device_lock);
 LIST_HEAD(acpi_wakeup_device_list);

+struct acpi_device_bus_id{
+	char bus_id[9];
+	unsigned int instance_no;
+	struct list_head node;
+};
 static int acpi_eject_operation(acpi_handle handle, int lockable)
 {
 	struct acpi_object_list arg_list;
@@ -103,18 +109,61 @@

 static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);

-static void acpi_device_setup_files(struct acpi_device *dev)
+static ssize_t
+acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) {
+	struct acpi_device *acpi_dev = to_acpi_device(dev);
+
+	return sprintf(buf, "%s\n", acpi_dev->pnp.hardware_id);
+}
+static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
+
+static ssize_t
+acpi_device_path_show(struct device *dev, struct device_attribute *attr, char *buf) {
+	struct acpi_device *acpi_dev = to_acpi_device(dev);
+	struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
+	int result;
+
+	result = acpi_get_name(acpi_dev->handle, ACPI_FULL_PATHNAME, &path);
+	if(result)
+		goto end;
+
+	result = sprintf(buf, "%s\n", (char*)path.pointer);
+	kfree(path.pointer);
+  end:
+	return result;
+}
+static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL);
+
+static int acpi_device_setup_files(struct acpi_device *dev)
 {
 	acpi_status status;
 	acpi_handle temp;
-
-	/*
-	 * If device has _EJ0, 'eject' file is created that is used to trigger
-	 * hot-removal function from userland.
-	 */
+	int result = 0;
+
+	/*
+	 * Devices gotten from FADT don't have a "path" attribute
+	 */
+	if(dev->handle) {
+		result = device_create_file(&dev->dev, &dev_attr_path);
+		if(result)
+			goto end;
+	}
+
+	if(dev->flags.hardware_id) {
+		result = device_create_file(&dev->dev, &dev_attr_hid);
+		if(result)
+			goto end;
+	}
+
+        /*
+         * If device has _EJ0, 'eject' file is created that is used to trigger
+         * hot-removal function from userland.
+         */
 	status = acpi_get_handle(dev->handle, "_EJ0", &temp);
 	if (ACPI_SUCCESS(status))
-		device_create_file(&dev->dev, &dev_attr_eject);
+		result = device_create_file(&dev->dev, &dev_attr_eject);
+  end:
+	return result;
 }

 static void acpi_device_remove_files(struct acpi_device *dev)
@@ -129,6 +178,11 @@
 	status = acpi_get_handle(dev->handle, "_EJ0", &temp);
 	if (ACPI_SUCCESS(status))
 		device_remove_file(&dev->dev, &dev_attr_eject);
+
+	if(dev->flags.hardware_id)
+		device_remove_file(&dev->dev, &dev_attr_hid);
+	if(dev->handle)
+		device_remove_file(&dev->dev, &dev_attr_path);
 }
 /* --------------------------------------------------------------------------
 			ACPI Bus operations
@@ -260,9 +314,12 @@
 	.uevent		= acpi_device_uevent,
 };

-static void acpi_device_register(struct acpi_device *device,
+static int acpi_device_register(struct acpi_device *device,
 				 struct acpi_device *parent)
 {
+	int result;
+	struct acpi_device_bus_id *acpi_device_bus_id, *new_bus_id;
+	int found = 0;
 	/*
 	 * Linkage
 	 * -------
@@ -273,7 +330,33 @@
 	INIT_LIST_HEAD(&device->g_list);
 	INIT_LIST_HEAD(&device->wakeup_list);

+	new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL);
+	if (!new_bus_id) {
+		printk(KERN_ERR PREFIX "Memory allocation error\n");
+		return -ENOMEM;
+	}
+
 	spin_lock(&acpi_device_lock);
+	/*
+	 * Find suitable bus_id and instance number in acpi_bus_id_list
+	 * If failed, create one and link it into acpi_bus_id_list
+	 */
+	list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node) {
+		if(!strcmp(acpi_device_bus_id->bus_id, device->flags.hardware_id? device->pnp.hardware_id : "PNPIDNON")) {
+			acpi_device_bus_id->instance_no ++;
+			found = 1;
+			kfree(new_bus_id);
+			break;
+		}
+	}
+	if(!found) {
+		acpi_device_bus_id = new_bus_id;
+		strcpy(acpi_device_bus_id->bus_id, device->flags.hardware_id ? device->pnp.hardware_id : "PNPIDNON");
+		acpi_device_bus_id->instance_no = 0;
+		list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list);
+	}
+	sprintf(device->dev.bus_id, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no);
+
 	if (device->parent) {
 		list_add_tail(&device->node, &device->parent->children);
 		list_add_tail(&device->g_list, &device->parent->g_list);
@@ -287,12 +370,29 @@
 		device->dev.parent = &parent->dev;
 	device->dev.bus = &acpi_bus_type;
 	device_initialize(&device->dev);
-	sprintf(device->dev.bus_id, "%s", device->pnp.bus_id);
 	device->dev.release = &acpi_device_release;
-	device_add(&device->dev);
-
-	acpi_device_setup_files(device);
+	result = device_add(&device->dev);
+	if(result) {
+		printk("Error adding device %s", device->dev.bus_id);
+		goto end;
+	}
+
+	result = acpi_device_setup_files(device);
+	if(result)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error creating sysfs interface for device %s\n", device->dev.bus_id));
+
 	device->removal_type = ACPI_BUS_REMOVAL_NORMAL;
+	return 0;
+  end:
+	spin_lock(&acpi_device_lock);
+	if (device->parent) {
+		list_del(&device->node);
+		list_del(&device->g_list);
+	} else
+		list_del(&device->g_list);
+	list_del(&device->wakeup_list);
+	spin_unlock(&acpi_device_lock);
+	return result;
 }

 static void acpi_device_unregister(struct acpi_device *device, int type)
@@ -1035,7 +1135,7 @@

 	acpi_device_get_debug_info(device, handle, type);

-	acpi_device_register(device, parent);
+	result = acpi_device_register(device, parent);

       end:
 	if (!result)


Remove some no longer needed debug logging.

git-svn-id: d8f21eb7283bfb39ebab2f8f9b4a259b233f9348@16 621663c8-3916-0410-8f58-edc14a8543d5

--- FFusionCodec.c
+++ FFusionCodec.c
@@ -193,9 +193,7 @@

             if (bitfield >= 0x1010)
             {
-                Codecprintf("Use speedy y420 component");
-                printf(" 0x%lx\n", bitfield);
-
+                Codecprintf("Use speedy y420 component");
                 glob->hasy420 = 1;
             }
         }
@@ -208,7 +206,6 @@
         // most of our calls to the base decompressor instance

         err = OpenADefaultComponent(decompressorComponentType, kBaseCodecType, &glob->delegateComponent);
-        printf("Perian codec: glob->delegateComponent:0x%x \n",glob->delegateComponent);
         if (!err)
         {
             ComponentSetTarget(glob->delegateComponent, self);


nbd: limit module parameters to a sane value

The 'max_part' parameter controls the number of maximum partition
a nbd device can have. However if a user specifies very large
value it would exceed the limitation of device minor number and
can cause a kernel oops (or, at least, produce invalid device
nodes in some cases).

In addition, specifying large 'nbds_max' value causes same
problem for the same reason.

On my desktop, following command results to the kernel bug:

$ sudo modprobe nbd max_part=100000
 kernel BUG at /media/Linux_Data/project/linux/fs/sysfs/group.c:65!
 invalid opcode: 0000 [#1] SMP
 last sysfs file: /sys/devices/virtual/block/nbd4/range
 CPU 1
 Modules linked in: nbd(+) bridge stp llc kvm_intel kvm asus_atk0110 sg sr_mod cdrom

 Pid: 2522, comm: modprobe Tainted: G        W   2.6.39-leonard+ #159 System manufacturer System Product Name/P5G41TD-M PRO
 RIP: 0010:[<ffffffff8115aa08>]  [<ffffffff8115aa08>] internal_create_group+0x2f/0x166
 RSP: 0018:ffff8801009f1de8  EFLAGS: 00010246
 RAX: 00000000ffffffef RBX: ffff880103920478 RCX: 00000000000a7bd3
 RDX: ffffffff81a2dbe0 RSI: 0000000000000000 RDI: ffff880103920478
 RBP: ffff8801009f1e38 R08: ffff880103920468 R09: ffff880103920478
 R10: ffff8801009f1de8 R11: ffff88011eccbb68 R12: ffffffff81a2dbe0
 R13: ffff880103920468 R14: 0000000000000000 R15: ffff880103920400
 FS:  00007f3c49de9700(0000) GS:ffff88011f800000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
 CR2: 00007f3b7fe7c000 CR3: 00000000cd58d000 CR4: 00000000000406e0
 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
 Process modprobe (pid: 2522, threadinfo ffff8801009f0000, task ffff8801009a93a0)
 Stack:
  ffff8801009f1e58 ffffffff812e8f6e ffff8801009f1e58 ffffffff812e7a80
  ffff880000000010 ffff880103920400 ffff8801002fd0c0 ffff880103920468
  0000000000000011 ffff880103920400 ffff8801009f1e48 ffffffff8115ab6a
 Call Trace:
  [<ffffffff812e8f6e>] ? device_add+0x4f1/0x5e4
  [<ffffffff812e7a80>] ? dev_set_name+0x41/0x43
  [<ffffffff8115ab6a>] sysfs_create_group+0x13/0x15
  [<ffffffff810b857e>] blk_trace_init_sysfs+0x14/0x16
  [<ffffffff811ee58b>] blk_register_queue+0x4c/0xfd
  [<ffffffff811f3bdf>] add_disk+0xe4/0x29c
  [<ffffffffa007e2ab>] nbd_init+0x2ab/0x30d [nbd]
  [<ffffffffa007e000>] ? 0xffffffffa007dfff
  [<ffffffff8100020f>] do_one_initcall+0x7f/0x13e
  [<ffffffff8107ab0a>] sys_init_module+0xa1/0x1e3
  [<ffffffff814f3542>] system_call_fastpath+0x16/0x1b
 Code: 41 57 41 56 41 55 41 54 53 48 83 ec 28 0f 1f 44 00 00 48 89 fb 41 89 f6 49 89 d4 48 85 ff 74 0b 85 f6 75 0b 48 83
  7f 30 00 75 14 <0f> 0b eb fe b9 ea ff ff ff 48 83 7f 30 00 0f 84 09 01 00 00 49
 RIP  [<ffffffff8115aa08>] internal_create_group+0x2f/0x166
  RSP <ffff8801009f1de8>
 ---[ end trace 753285ffbf72c57c ]---

Signed-off-by: Namhyung Kim <5c915a589b3ddf58cebf14bec41bcc143b37ac3c@gmail.com>
Cc: Laurent Vivier <1339eb1aa06789b4225d52dda27239a91886e148@bull.net>
Cc: Paul Clements <76d5feb7143d471cd747aca15dce1a0d6d9699ed@steeleye.com>
Cc: 4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@kernel.org
Signed-off-by: Jens Axboe <08e836a620179c237f631ad0545a7ebdf54201f3@fusionio.com>

--- drivers/block/nbd.c
+++ drivers/block/nbd.c
@@ -756,6 +756,12 @@
 	part_shift = 0;
 	if (max_part > 0)
 		part_shift = fls(max_part);
+
+	if ((1UL << part_shift) > DISK_MAX_PARTS)
+		return -EINVAL;
+
+	if (nbds_max > 1UL << (MINORBITS - part_shift))
+		return -EINVAL;

 	for (i = 0; i < nbds_max; i++) {
 		struct gendisk *disk = alloc_disk(1 << part_shift);


nodeset status change

nodeset status change

--- src/store/redis/redis_nodeset.c
+++ src/store/redis/redis_nodeset.c
@@ -821,7 +821,9 @@
         redisAsyncCommand(node->ctx.cmd, node_connector_callback, node, "SCRIPT LOAD %s", next_script->script);
         return;
       }
-      node_log_notice(node, "all scripts loaded!");
+      node_log_info(node, "all scripts loaded");
+      node->state = REDIS_NODE_READY;
+      nodeset_check_status(node->nodeset);
   }
 }

@@ -890,27 +892,31 @@
   }
   if(ready == total) {
     if(ready == 0) {
-      nodeset_set_status(nodeset, REDIS_NODESET_INVALID, "no reachable servers");
+      nodeset_set_status(nodeset, REDIS_NODESET_INVALID, "no reachable Redis servers");
     }
     else if(cluster && cluster < total) {
-      nodeset_set_status(nodeset, REDIS_NODESET_INVALID, "cluster and non-cluster servers in set");
+      nodeset_set_status(nodeset, REDIS_NODESET_INVALID, "cluster and non-cluster Redis servers in set");
     }
     else if (cluster == 0 && masters > 1) {
-      nodeset_set_status(nodeset, REDIS_NODESET_INVALID, "more than one master servers in non-cluster set");
+      nodeset_set_status(nodeset, REDIS_NODESET_INVALID, "more than one master Redis servers in non-cluster set");
     }
     else if (cluster == 0 && masters == 0) {
-      nodeset_set_status(nodeset, REDIS_NODESET_INVALID, "no reachable master servers in set");
+      nodeset_set_status(nodeset, REDIS_NODESET_INVALID, "no reachable master Redis servers in set");
+    }
+    else if(cluster > 0 && nodeset_cluster_keyslot_space_complete(nodeset)) {
+      nodeset_set_status(nodeset, REDIS_NODESET_CONNECTING, "keyslot space incomplete");
     }
     else {
-      nodeset_set_status(nodeset, REDIS_NODESET_READY, NULL);
+      nodeset_set_status(nodeset, REDIS_NODESET_READY, cluster > 0 ? "Redis cluster ready" : "Redis server ready");
     }
   }
   else if(ready == 0) {
-    nodeset_set_status(nodeset, REDIS_NODESET_DISCONNECTED, NULL);
+    nodeset_set_status(nodeset, REDIS_NODESET_DISCONNECTED, "no connected Redis servers");
   }
   else if(ready < total) {
-    nodeset_set_status(nodeset, REDIS_NODESET_CONNECTING, NULL);
-  }
+    nodeset_set_status(nodeset, REDIS_NODESET_CONNECTING, "not all Redis servers are connected");
+  }
+
   return NGX_OK;
 }


rbd: do not duplicate ceph_client pointer in rbd_device

The rbd_device structure maintains a duplicate copy of the
ceph_client pointer maintained in its rbd_client structure.  There
appears to be no good reason for this, and its presence presents a
risk of them getting out of synch or otherwise misused.  So kill it
off, and use the rbd_client copy only.

Signed-off-by: Alex Elder <f429030cf5c0faf36fac3d102073b6e63a647baa@dreamhost.com>
Signed-off-by: Sage Weil <6dd34506bbd5e58221bbb3e4732d97c91f02277b@newdream.net>

--- drivers/block/rbd.c
+++ drivers/block/rbd.c
@@ -140,7 +140,6 @@
 	struct gendisk		*disk;		/* blkdev's gendisk and rq */
 	struct request_queue	*q;

-	struct ceph_client	*client;
 	struct rbd_client	*rbd_client;

 	char			name[DEV_NAME_LEN]; /* blkdev name, e.g. rbd3 */
@@ -388,7 +387,6 @@
 		/* using an existing client */
 		kref_get(&rbdc->kref);
 		rbd_dev->rbd_client = rbdc;
-		rbd_dev->client = rbdc->client;
 		spin_unlock(&node_lock);
 		return 0;
 	}
@@ -401,7 +399,6 @@
 	}

 	rbd_dev->rbd_client = rbdc;
-	rbd_dev->client = rbdc->client;
 	return 0;
 done_err:
 	kfree(rbd_opts);
@@ -435,7 +432,6 @@
 	kref_put(&rbd_dev->rbd_client->kref, rbd_client_release);
 	spin_unlock(&node_lock);
 	rbd_dev->rbd_client = NULL;
-	rbd_dev->client = NULL;
 }

 /*
@@ -858,6 +854,7 @@
 	struct rbd_request *req_data;
 	struct ceph_osd_request_head *reqhead;
 	struct rbd_image_header *header = &dev->header;
+	struct ceph_osd_client *osdc;

 	req_data = kzalloc(sizeof(*req_data), GFP_NOIO);
 	if (!req_data) {
@@ -876,11 +873,9 @@

 	down_read(&header->snap_rwsem);

-	req = ceph_osdc_alloc_request(&dev->client->osdc, flags,
-				      snapc,
-				      ops,
-				      false,
-				      GFP_NOIO, pages, bio);
+	osdc = &dev->rbd_client->client->osdc;
+	req = ceph_osdc_alloc_request(osdc, flags, snapc, ops,
+					false, GFP_NOIO, pages, bio);
 	if (!req) {
 		up_read(&header->snap_rwsem);
 		ret = -ENOMEM;
@@ -909,8 +904,8 @@
 	layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
 	layout->fl_pg_preferred = cpu_to_le32(-1);
 	layout->fl_pg_pool = cpu_to_le32(dev->poolid);
-	ceph_calc_raw_layout(&dev->client->osdc, layout, snapid,
-			     ofs, &len, &bno, req, ops);
+	ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno,
+				req, ops);

 	ceph_osdc_build_request(req, ofs, &len,
 				ops,
@@ -920,16 +915,16 @@
 	up_read(&header->snap_rwsem);

 	if (linger_req) {
-		ceph_osdc_set_request_linger(&dev->client->osdc, req);
+		ceph_osdc_set_request_linger(osdc, req);
 		*linger_req = req;
 	}

-	ret = ceph_osdc_start_request(&dev->client->osdc, req, false);
+	ret = ceph_osdc_start_request(osdc, req, false);
 	if (ret < 0)
 		goto done_err;

 	if (!rbd_cb) {
-		ret = ceph_osdc_wait_request(&dev->client->osdc, req);
+		ret = ceph_osdc_wait_request(osdc, req);
 		if (ver)
 			*ver = le64_to_cpu(req->r_reassert_version.version);
 		dout("reassert_ver=%lld\n",
@@ -1227,7 +1222,7 @@
 			      u64 ver)
 {
 	struct ceph_osd_req_op *ops;
-	struct ceph_osd_client *osdc = &dev->client->osdc;
+	struct ceph_osd_client *osdc = &dev->rbd_client->client->osdc;

 	int ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_WATCH, 0);
 	if (ret < 0)
@@ -1314,7 +1309,7 @@
 		          const char *obj)
 {
 	struct ceph_osd_req_op *ops;
-	struct ceph_osd_client *osdc = &dev->client->osdc;
+	struct ceph_osd_client *osdc = &dev->rbd_client->client->osdc;
 	struct ceph_osd_event *event;
 	struct rbd_notify_info info;
 	int payload_len = sizeof(u32) + sizeof(u32);
@@ -1623,13 +1618,14 @@
 	int ret;
 	void *data, *p, *e;
 	u64 ver;
+	struct ceph_mon_client *monc;

 	/* we should create a snapshot only if we're pointing at the head */
 	if (dev->cur_snap)
 		return -EINVAL;

-	ret = ceph_monc_create_snapid(&dev->client->monc, dev->poolid,
-				      &new_snapid);
+	monc = &dev->rbd_client->client->monc;
+	ret = ceph_monc_create_snapid(monc, dev->poolid, &new_snapid);
 	dout("created snapid=%lld\n", new_snapid);
 	if (ret < 0)
 		return ret;
@@ -1809,7 +1805,8 @@
 {
 	struct rbd_device *rbd_dev = dev_to_rbd(dev);

-	return sprintf(buf, "client%lld\n", ceph_client_id(rbd_dev->client));
+	return sprintf(buf, "client%lld\n",
+			ceph_client_id(rbd_dev->rbd_client->client));
 }

 static ssize_t rbd_pool_show(struct device *dev,
@@ -2233,7 +2230,7 @@
 	mutex_unlock(&ctl_mutex);

 	/* pick the pool */
-	osdc = &rbd_dev->client->osdc;
+	osdc = &rbd_dev->rbd_client->client->osdc;
 	rc = ceph_pg_poolid_by_name(osdc->osdmap, rbd_dev->pool_name);
 	if (rc < 0)
 		goto err_out_client;
@@ -2312,9 +2309,12 @@
 	struct rbd_device *rbd_dev =
 			container_of(dev, struct rbd_device, dev);

-	if (rbd_dev->watch_request)
-		ceph_osdc_unregister_linger_request(&rbd_dev->client->osdc,
+	if (rbd_dev->watch_request) {
+		struct ceph_client *client = rbd_dev->rbd_client->client;
+
+		ceph_osdc_unregister_linger_request(&client->osdc,
 						    rbd_dev->watch_request);
+	}
 	if (rbd_dev->watch_event)
 		rbd_req_sync_unwatch(rbd_dev, rbd_dev->obj_md_name);


rbd: kill rbd_req_sync_op() snapc and snapid parameters

The snapc and snapid parameters to rbd_req_sync_op() always take
the values NULL and CEPH_NOSNAP, respectively.  So just get rid
of them and use those values where needed.

Signed-off-by: Alex Elder <f429030cf5c0faf36fac3d102073b6e63a647baa@inktank.com>
Reviewed-by: Josh Durgin <51652c783f70f5b272ebd02f1fd20d3af7a2449f@inktank.com>

--- drivers/block/rbd.c
+++ drivers/block/rbd.c
@@ -1257,8 +1257,6 @@
  * Do a synchronous ceph osd operation
  */
 static int rbd_req_sync_op(struct rbd_device *rbd_dev,
-			   struct ceph_snap_context *snapc,
-			   u64 snapid,
 			   int flags,
 			   struct ceph_osd_req_op *ops,
 			   const char *object_name,
@@ -1278,7 +1276,7 @@
 	if (IS_ERR(pages))
 		return PTR_ERR(pages);

-	ret = rbd_do_request(NULL, rbd_dev, snapc, snapid,
+	ret = rbd_do_request(NULL, rbd_dev, NULL, CEPH_NOSNAP,
 			  object_name, ofs, inbound_size, NULL,
 			  pages, num_pages,
 			  flags,
@@ -1380,9 +1378,7 @@
 	if (!ops)
 		return -ENOMEM;

-	ret = rbd_req_sync_op(rbd_dev, NULL,
-			       CEPH_NOSNAP,
-			       CEPH_OSD_FLAG_READ,
+	ret = rbd_req_sync_op(rbd_dev, CEPH_OSD_FLAG_READ,
 			       ops, object_name, ofs, len, buf, NULL, ver);
 	rbd_destroy_ops(ops);

@@ -1461,8 +1457,7 @@
 	ops[0].watch.cookie = cpu_to_le64(rbd_dev->watch_event->cookie);
 	ops[0].watch.flag = 1;

-	ret = rbd_req_sync_op(rbd_dev, NULL,
-			      CEPH_NOSNAP,
+	ret = rbd_req_sync_op(rbd_dev,
 			      CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
 			      ops,
 			      rbd_dev->header_name,
@@ -1499,8 +1494,7 @@
 	ops[0].watch.cookie = cpu_to_le64(rbd_dev->watch_event->cookie);
 	ops[0].watch.flag = 0;

-	ret = rbd_req_sync_op(rbd_dev, NULL,
-			      CEPH_NOSNAP,
+	ret = rbd_req_sync_op(rbd_dev,
 			      CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
 			      ops,
 			      rbd_dev->header_name,
@@ -1553,8 +1547,7 @@
 	ops[0].cls.indata = outbound;
 	ops[0].cls.indata_len = outbound_size;

-	ret = rbd_req_sync_op(rbd_dev, NULL,
-			       CEPH_NOSNAP, CEPH_OSD_FLAG_READ, ops,
+	ret = rbd_req_sync_op(rbd_dev, CEPH_OSD_FLAG_READ, ops,
 			       object_name, 0, inbound_size, inbound,
 			       NULL, ver);


md: raid 10 supports TRIM

md: raid 10 supports TRIM

This makes md raid 10 support TRIM.

If one disk supports discard and another not, or one has
discard_zero_data and another not, there could be inconsistent between
data from such disks. But this should not matter, discarded data is
useless. This will add extra copy in rebuild though.

Signed-off-by: Shaohua Li <c0c0c8857ed6ec93282de3ee9d47e224acf995af@fusionio.com>
Signed-off-by: NeilBrown <1c00aa603bb92d594c03cff60ecf8e63b2a5bcb1@suse.de>

--- drivers/md/raid10.c
+++ drivers/md/raid10.c
@@ -911,7 +911,12 @@
 		while (bio) { /* submit pending writes */
 			struct bio *next = bio->bi_next;
 			bio->bi_next = NULL;
-			generic_make_request(bio);
+			if (unlikely((bio->bi_rw & REQ_DISCARD) &&
+			    !blk_queue_discard(bdev_get_queue(bio->bi_bdev))))
+				/* Just ignore it */
+				bio_endio(bio, 0);
+			else
+				generic_make_request(bio);
 			bio = next;
 		}
 	} else
@@ -1061,6 +1066,8 @@
 	const int rw = bio_data_dir(bio);
 	const unsigned long do_sync = (bio->bi_rw & REQ_SYNC);
 	const unsigned long do_fua = (bio->bi_rw & REQ_FUA);
+	const unsigned long do_discard = (bio->bi_rw
+					  & (REQ_DISCARD | REQ_SECURE));
 	unsigned long flags;
 	struct md_rdev *blocked_rdev;
 	int sectors_handled;
@@ -1081,7 +1088,7 @@
 			 || conf->prev.near_copies < conf->prev.raid_disks))) {
 		struct bio_pair *bp;
 		/* Sanity check -- queue functions should prevent this happening */
-		if (bio->bi_vcnt != 1 ||
+		if ((bio->bi_vcnt != 1 && bio->bi_vcnt != 0) ||
 		    bio->bi_idx != 0)
 			goto bad_map;
 		/* This is a one page bio that upper layers
@@ -1410,7 +1417,7 @@
 						      conf->mirrors[d].rdev));
 		mbio->bi_bdev = conf->mirrors[d].rdev->bdev;
 		mbio->bi_end_io	= raid10_end_write_request;
-		mbio->bi_rw = WRITE | do_sync | do_fua;
+		mbio->bi_rw = WRITE | do_sync | do_fua | do_discard;
 		mbio->bi_private = r10_bio;

 		atomic_inc(&r10_bio->remaining);
@@ -1439,7 +1446,7 @@
 					   conf->mirrors[d].replacement));
 		mbio->bi_bdev = conf->mirrors[d].replacement->bdev;
 		mbio->bi_end_io	= raid10_end_write_request;
-		mbio->bi_rw = WRITE | do_sync | do_fua;
+		mbio->bi_rw = WRITE | do_sync | do_fua | do_discard;
 		mbio->bi_private = r10_bio;

 		atomic_inc(&r10_bio->remaining);
@@ -1723,6 +1730,9 @@
 		clear_bit(Unmerged, &rdev->flags);
 	}
 	md_integrity_add_rdev(rdev, mddev);
+	if (blk_queue_discard(bdev_get_queue(rdev->bdev)))
+		queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);
+
 	print_conf(conf);
 	return err;
 }
@@ -3480,6 +3490,7 @@
 	sector_t size;
 	sector_t min_offset_diff = 0;
 	int first = 1;
+	bool discard_supported = false;

 	if (mddev->private == NULL) {
 		conf = setup_conf(mddev);
@@ -3496,6 +3507,8 @@

 	chunk_size = mddev->chunk_sectors << 9;
 	if (mddev->queue) {
+		blk_queue_max_discard_sectors(mddev->queue,
+					      mddev->chunk_sectors);
 		blk_queue_io_min(mddev->queue, chunk_size);
 		if (conf->geo.raid_disks % conf->geo.near_copies)
 			blk_queue_io_opt(mddev->queue, chunk_size * conf->geo.raid_disks);
@@ -3541,7 +3554,15 @@
 					  rdev->data_offset << 9);

 		disk->head_position = 0;
-	}
+
+		if (blk_queue_discard(bdev_get_queue(rdev->bdev)))
+			discard_supported = true;
+	}
+
+	if (discard_supported)
+		queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);
+	else
+		queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);

 	/* need to check that every block has at least one working mirror */
 	if (!enough(conf, -1)) {


md/raid10: avoid reading from known bad blocks - part 2

When redirecting a read error to a different device, we must
again avoid bad blocks and possibly split the request.

Spin_lock typo fixed thanks to Dan Carpenter <error27@gmail.com>

Signed-off-by: NeilBrown <1c00aa603bb92d594c03cff60ecf8e63b2a5bcb1@suse.de>

--- drivers/md/raid10.c
+++ drivers/md/raid10.c
@@ -1746,14 +1746,15 @@
 	rdev_dec_pending(conf->mirrors[mirror].rdev, mddev);

 	bio = r10_bio->devs[slot].bio;
+	bdevname(bio->bi_bdev, b);
 	r10_bio->devs[slot].bio =
 		mddev->ro ? IO_BLOCKED : NULL;
+read_more:
 	mirror = read_balance(conf, r10_bio, &max_sectors);
-	if (mirror == -1 || max_sectors < r10_bio->sectors) {
+	if (mirror == -1) {
 		printk(KERN_ALERT "md/raid10:%s: %s: unrecoverable I/O"
 		       " read error for block %llu\n",
-		       mdname(mddev),
-		       bdevname(bio->bi_bdev, b),
+		       mdname(mddev), b,
 		       (unsigned long long)r10_bio->sector);
 		raid_end_bio_io(r10_bio);
 		bio_put(bio);
@@ -1761,7 +1762,8 @@
 	}

 	do_sync = (r10_bio->master_bio->bi_rw & REQ_SYNC);
-	bio_put(bio);
+	if (bio)
+		bio_put(bio);
 	slot = r10_bio->read_slot;
 	rdev = conf->mirrors[mirror].rdev;
 	printk_ratelimited(
@@ -1773,6 +1775,9 @@
 		(unsigned long long)r10_bio->sector);
 	bio = bio_clone_mddev(r10_bio->master_bio,
 			      GFP_NOIO, mddev);
+	md_trim_bio(bio,
+		    r10_bio->sector - bio->bi_sector,
+		    max_sectors);
 	r10_bio->devs[slot].bio = bio;
 	bio->bi_sector = r10_bio->devs[slot].addr
 		+ rdev->data_offset;
@@ -1780,7 +1785,37 @@
 	bio->bi_rw = READ | do_sync;
 	bio->bi_private = r10_bio;
 	bio->bi_end_io = raid10_end_read_request;
-	generic_make_request(bio);
+	if (max_sectors < r10_bio->sectors) {
+		/* Drat - have to split this up more */
+		struct bio *mbio = r10_bio->master_bio;
+		int sectors_handled =
+			r10_bio->sector + max_sectors
+			- mbio->bi_sector;
+		r10_bio->sectors = max_sectors;
+		spin_lock_irq(&conf->device_lock);
+		if (mbio->bi_phys_segments == 0)
+			mbio->bi_phys_segments = 2;
+		else
+			mbio->bi_phys_segments++;
+		spin_unlock_irq(&conf->device_lock);
+		generic_make_request(bio);
+		bio = NULL;
+
+		r10_bio = mempool_alloc(conf->r10bio_pool,
+					GFP_NOIO);
+		r10_bio->master_bio = mbio;
+		r10_bio->sectors = (mbio->bi_size >> 9)
+			- sectors_handled;
+		r10_bio->state = 0;
+		set_bit(R10BIO_ReadError,
+			&r10_bio->state);
+		r10_bio->mddev = mddev;
+		r10_bio->sector = mbio->bi_sector
+			+ sectors_handled;
+
+		goto read_more;
+	} else
+		generic_make_request(bio);
 }

 static void raid10d(mddev_t *mddev)


mfd: stmpe: Use devm_*() routines

mfd: stmpe: Use devm_*() routines

This patch frees stmpe driver from tension of freeing resources.
devm_* derivatives of multiple routines are used while allocating resources,
which would be freed automatically by kernel.

Signed-off-by: Viresh Kumar <5ff32272b3d9f86512eddc8e0af523fc6f7924e5@linaro.org>
Acked-by: Lee Jones <630e34333487a351a857f6b705e04d30b37c1629@linaro.org>
Signed-off-by: Samuel Ortiz <0ba86cb3f08bbb861958e54bd3438887adb4263c@linux.intel.com>

--- drivers/mfd/stmpe.c
+++ drivers/mfd/stmpe.c
@@ -1052,17 +1052,17 @@
 	int ret;

 	if (!pdata) {
-		if (np) {
-			pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
-			if (!pdata)
-				return -ENOMEM;
-
-			stmpe_of_probe(pdata, np);
-		} else
+		if (!np)
 			return -EINVAL;
-	}
-
-	stmpe = kzalloc(sizeof(struct stmpe), GFP_KERNEL);
+
+		pdata = devm_kzalloc(ci->dev, sizeof(*pdata), GFP_KERNEL);
+		if (!pdata)
+			return -ENOMEM;
+
+		stmpe_of_probe(pdata, np);
+	}
+
+	stmpe = devm_kzalloc(ci->dev, sizeof(struct stmpe), GFP_KERNEL);
 	if (!stmpe)
 		return -ENOMEM;

@@ -1084,11 +1084,12 @@
 		ci->init(stmpe);

 	if (pdata->irq_over_gpio) {
-		ret = gpio_request_one(pdata->irq_gpio, GPIOF_DIR_IN, "stmpe");
+		ret = devm_gpio_request_one(ci->dev, pdata->irq_gpio,
+				GPIOF_DIR_IN, "stmpe");
 		if (ret) {
 			dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n",
 					ret);
-			goto out_free;
+			return ret;
 		}

 		stmpe->irq = gpio_to_irq(pdata->irq_gpio);
@@ -1105,62 +1106,43 @@
 			dev_err(stmpe->dev,
 				"%s does not support no-irq mode!\n",
 				stmpe->variant->name);
-			ret = -ENODEV;
-			goto free_gpio;
+			return -ENODEV;
 		}
 		stmpe->variant = stmpe_noirq_variant_info[stmpe->partnum];
 	}

 	ret = stmpe_chip_init(stmpe);
 	if (ret)
-		goto free_gpio;
+		return ret;

 	if (stmpe->irq >= 0) {
 		ret = stmpe_irq_init(stmpe, np);
 		if (ret)
-			goto free_gpio;
-
-		ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq,
-				pdata->irq_trigger | IRQF_ONESHOT,
+			return ret;
+
+		ret = devm_request_threaded_irq(ci->dev, stmpe->irq, NULL,
+				stmpe_irq, pdata->irq_trigger | IRQF_ONESHOT,
 				"stmpe", stmpe);
 		if (ret) {
 			dev_err(stmpe->dev, "failed to request IRQ: %d\n",
 					ret);
-			goto free_gpio;
+			return ret;
 		}
 	}

 	ret = stmpe_devices_init(stmpe);
-	if (ret) {
-		dev_err(stmpe->dev, "failed to add children\n");
-		goto out_removedevs;
-	}
-
-	return 0;
-
-out_removedevs:
+	if (!ret)
+		return 0;
+
+	dev_err(stmpe->dev, "failed to add children\n");
 	mfd_remove_devices(stmpe->dev);
-	if (stmpe->irq >= 0)
-		free_irq(stmpe->irq, stmpe);
-free_gpio:
-	if (pdata->irq_over_gpio)
-		gpio_free(pdata->irq_gpio);
-out_free:
-	kfree(stmpe);
+
 	return ret;
 }

 int stmpe_remove(struct stmpe *stmpe)
 {
 	mfd_remove_devices(stmpe->dev);
-
-	if (stmpe->irq >= 0)
-		free_irq(stmpe->irq, stmpe);
-
-	if (stmpe->pdata->irq_over_gpio)
-		gpio_free(stmpe->pdata->irq_gpio);
-
-	kfree(stmpe);

 	return 0;
 }


82596: free resources on error

82596: free resources on error

IRQ 56 was not freed anywhere (neither in i596_open() on error nor in
i596_close()), rx_bufs were not freed if init_i596_mem() fails,
netif_stop_queue() was not called.

Signed-off-by: Kulikov Vasiliy <bf62e7c380ff4449c5c3c5c39150b7660ee28ecb@gmail.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/82596.c
+++ drivers/net/82596.c
@@ -1015,23 +1015,34 @@
 	}
 #ifdef ENABLE_MVME16x_NET
 	if (MACH_IS_MVME16x) {
-		if (request_irq(0x56, i596_error, 0, "i82596_error", dev))
-			return -EAGAIN;
+		if (request_irq(0x56, i596_error, 0, "i82596_error", dev)) {
+			res = -EAGAIN;
+			goto err_irq_dev;
+		}
 	}
 #endif
 	res = init_rx_bufs(dev);
-	if (res) {
-		free_irq(dev->irq, dev);
-		return res;
-	}
+	if (res)
+		goto err_irq_56;

 	netif_start_queue(dev);

-	/* Initialize the 82596 memory */
 	if (init_i596_mem(dev)) {
 		res = -EAGAIN;
-		free_irq(dev->irq, dev);
-	}
+		goto err_queue;
+	}
+
+	return 0;
+
+err_queue:
+	netif_stop_queue(dev);
+	remove_rx_bufs(dev);
+err_irq_56:
+#ifdef ENABLE_MVME16x_NET
+	free_irq(0x56, dev);
+#endif
+err_irq_dev:
+	free_irq(dev->irq, dev);

 	return res;
 }
@@ -1498,6 +1509,9 @@
 	}
 #endif

+#ifdef ENABLE_MVME16x_NET
+	free_irq(0x56, dev);
+#endif
 	free_irq(dev->irq, dev);
 	remove_rx_bufs(dev);


r8169: issue request_irq after the private data are completely initialized

The irq handler schedules a NAPI poll request unconditionally as soon as
the status register is not clean. It has been there - and wrong - for
ages but a recent timing change made it apparently easier to trigger.

Signed-off-by: Francois Romieu <b6456b24ae82a7595be3173ae585c7a827f25f37@fr.zoreil.com>
Cc: Jay Cliburn <d11bee250b03481f44fa3a0535527d169f2738a9@bellsouth.net>
Signed-off-by: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>

--- drivers/net/r8169.c
+++ drivers/net/r8169.c
@@ -66,6 +66,7 @@
 #include <linux/init.h>
 #include <linux/dma-mapping.h>

+#include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>

@@ -486,6 +487,7 @@
 				void __iomem *);
 static int rtl8169_change_mtu(struct net_device *dev, int new_mtu);
 static void rtl8169_down(struct net_device *dev);
+static void rtl8169_rx_clear(struct rtl8169_private *tp);

 #ifdef CONFIG_R8169_NAPI
 static int rtl8169_poll(struct net_device *dev, int *budget);
@@ -1751,16 +1753,10 @@
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
 	struct pci_dev *pdev = tp->pci_dev;
-	int retval;
+	int retval = -ENOMEM;
+

 	rtl8169_set_rxbufsize(tp, dev);
-
-	retval =
-	    request_irq(dev->irq, rtl8169_interrupt, IRQF_SHARED, dev->name, dev);
-	if (retval < 0)
-		goto out;
-
-	retval = -ENOMEM;

 	/*
 	 * Rx and Tx desscriptors needs 256 bytes alignment.
@@ -1769,18 +1765,25 @@
 	tp->TxDescArray = pci_alloc_consistent(pdev, R8169_TX_RING_BYTES,
 					       &tp->TxPhyAddr);
 	if (!tp->TxDescArray)
-		goto err_free_irq;
+		goto out;

 	tp->RxDescArray = pci_alloc_consistent(pdev, R8169_RX_RING_BYTES,
 					       &tp->RxPhyAddr);
 	if (!tp->RxDescArray)
-		goto err_free_tx;
+		goto err_free_tx_0;

 	retval = rtl8169_init_ring(dev);
 	if (retval < 0)
-		goto err_free_rx;
+		goto err_free_rx_1;

 	INIT_DELAYED_WORK(&tp->task, NULL);
+
+	smp_mb();
+
+	retval = request_irq(dev->irq, rtl8169_interrupt, IRQF_SHARED,
+			     dev->name, dev);
+	if (retval < 0)
+		goto err_release_ring_2;

 	rtl8169_hw_start(dev);

@@ -1790,14 +1793,14 @@
 out:
 	return retval;

-err_free_rx:
+err_release_ring_2:
+	rtl8169_rx_clear(tp);
+err_free_rx_1:
 	pci_free_consistent(pdev, R8169_RX_RING_BYTES, tp->RxDescArray,
 			    tp->RxPhyAddr);
-err_free_tx:
+err_free_tx_0:
 	pci_free_consistent(pdev, R8169_TX_RING_BYTES, tp->TxDescArray,
 			    tp->TxPhyAddr);
-err_free_irq:
-	free_irq(dev->irq, dev);
 	goto out;
 }


r8169: support new firmware format.

r8169: support new firmware format.

The new firmware format adds versioning as firmware for a specific
chipset appears to be subject to change. Current "legacy" format is
still supported.

Signed-off-by: Hayes Wang <2e4abddca5cd1005ec71becebc17a5257b0bced7@realtek.com>
Signed-off-by: Francois Romieu <b6456b24ae82a7595be3173ae585c7a827f25f37@fr.zoreil.com>

--- drivers/net/r8169.c
+++ drivers/net/r8169.c
@@ -1754,18 +1754,52 @@
 #define PHY_DELAY_MS		0xe0000000
 #define PHY_WRITE_ERI_WORD	0xf0000000

+struct fw_info {
+	u32	magic;
+	char	version[RTL_VER_SIZE];
+	__le32	fw_start;
+	__le32	fw_len;
+	u8	chksum;
+} __packed;
+
 #define FW_OPCODE_SIZE	sizeof(typeof(*((struct rtl_fw_phy_action *)0)->code))

 static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 {
 	const struct firmware *fw = rtl_fw->fw;
+	struct fw_info *fw_info = (struct fw_info *)fw->data;
 	struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
 	char *version = rtl_fw->version;
 	bool rc = false;

 	if (fw->size < FW_OPCODE_SIZE)
 		goto out;
-	else {
+
+	if (!fw_info->magic) {
+		size_t i, size, start;
+		u8 checksum = 0;
+
+		if (fw->size < sizeof(*fw_info))
+			goto out;
+
+		for (i = 0; i < fw->size; i++)
+			checksum += fw->data[i];
+		if (checksum != 0)
+			goto out;
+
+		start = le32_to_cpu(fw_info->fw_start);
+		if (start > fw->size)
+			goto out;
+
+		size = le32_to_cpu(fw_info->fw_len);
+		if (size > (fw->size - start) / FW_OPCODE_SIZE)
+			goto out;
+
+		memcpy(version, fw_info->version, RTL_VER_SIZE);
+
+		pa->code = (__le32 *)(fw->data + start);
+		pa->size = size;
+	} else {
 		if (fw->size % FW_OPCODE_SIZE)
 			goto out;


Switched a write to safeWrite in profile.c.

Cleaned up some code related to a now unneeded assertion.

--- sal/osl/unx/profile.c
+++ sal/osl/unx/profile.c
@@ -437,7 +437,6 @@

 static sal_Bool writeProfileImpl(osl_TFile* pFile)
 {
-    int BytesWritten=0;
 #if OSL_DEBUG_LEVEL > 1
     unsigned int nLen=0;
 #endif
@@ -459,18 +458,11 @@
     OSL_ASSERT(nLen == (pFile->m_nWriteBufLen - pFile->m_nWriteBufFree));
 #endif

-    BytesWritten = write(pFile->m_Handle, pFile->m_pWriteBuf, pFile->m_nWriteBufLen - pFile->m_nWriteBufFree);
-
-    if ( BytesWritten <= 0 )
+    if ( !safeWrite(pFile->m_Handle, pFile->m_pWriteBuf, pFile->m_nWriteBufLen - pFile->m_nWriteBufFree) )
     {
         OSL_TRACE("write failed '%s'\n",strerror(errno));
         return (sal_False);
     }
-
-#if OSL_DEBUG_LEVEL > 1
-    OSL_ASSERT(
-        BytesWritten >= 0 && SAL_INT_CAST(unsigned int, BytesWritten) == nLen);
-#endif

     free(pFile->m_pWriteBuf);
     pFile->m_pWriteBuf=0;


r8169: phy init for the 8169sce

r8169: phy init for the 8169sce

Synced with Realtek's 6.011.00 r8169 driver.

Signed-off-by: Francois Romieu <b6456b24ae82a7595be3173ae585c7a827f25f37@fr.zoreil.com>
Cc: Edward Hsu <27809cb3bef647511fa32cd6f89a201a998916de@realtek.com.tw>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


hpsa: eliminate fake lun0 enclosures

hpsa: eliminate fake lun0 enclosures

We don't need to create fake enclosure devices at Lun0
in external target array configurations anymore.
This was done to support Pre-SCSI rev 5 controllers
that didn't suppoprt report luns commands, so the
SCSI layer had to scan targets. If there was no
LUN at LUN 0, then the target scan would stop, and
move to the next target.  Lun0 enclosure device
was added to prevent sparsely-numbered LUNs from
being missed.

Reviewed-by: Scott Teel <a7e0ce414fba0c6a771cbc0f20d6d2c5203e64ca@pmcs.com>
Reviewed-by: Justin Lindley <019d02fa0753c9e0c2c196f9d4c3f4bcb8f82eb9@pmcs.com>
Reviewed-by: Kevin Barnett <41c5c2fac2360ea1d1744ec1b5a9c3fc6c0cbe74@pmcs.com>
Reviewed-by: Matthew R. Ochs <5279806d22638a7ca4d6f7841541587adc5832b0@linux.vnet.ibm.com>
Reviewed-by: Hannes Reinecke <b0d1e9e4a4e27620745ff49be9000da3174a4cc6@suse.de>
Reviewed-by: Tomas Henzl <ed03cdd404c1c501a81ee6cc756c3c81b1d33f83@redhat.com>
Signed-off-by: Don Brace <2492869e79b95109d0bee0fc4e8bb0141c1888c7@pmcs.com>
Signed-off-by: Martin K. Petersen <0384aaef27f06874adbdb09a807bb339f4aff9fd@oracle.com>

--- drivers/scsi/hpsa.c
+++ drivers/scsi/hpsa.c
@@ -3571,60 +3571,6 @@
 				0, lunid & 0x3fff);
 }

-/*
- * If there is no lun 0 on a target, linux won't find any devices.
- * For the external targets (arrays), we have to manually detect the enclosure
- * which is at lun zero, as CCISS_REPORT_PHYSICAL_LUNS doesn't report
- * it for some reason.  *tmpdevice is the target we're adding,
- * this_device is a pointer into the current element of currentsd[]
- * that we're building up in update_scsi_devices(), below.
- * lunzerobits is a bitmap that tracks which targets already have a
- * lun 0 assigned.
- * Returns 1 if an enclosure was added, 0 if not.
- */
-static int add_ext_target_dev(struct ctlr_info *h,
-	struct hpsa_scsi_dev_t *tmpdevice,
-	struct hpsa_scsi_dev_t *this_device, u8 *lunaddrbytes,
-	unsigned long lunzerobits[], int *n_ext_target_devs)
-{
-	unsigned char scsi3addr[8];
-
-	if (test_bit(tmpdevice->target, lunzerobits))
-		return 0; /* There is already a lun 0 on this target. */
-
-	if (!is_logical_dev_addr_mode(lunaddrbytes))
-		return 0; /* It's the logical targets that may lack lun 0. */
-
-	if (!tmpdevice->external)
-		return 0; /* Only external target devices have this problem. */
-
-	if (tmpdevice->lun == 0) /* if lun is 0, then we have a lun 0. */
-		return 0;
-
-	memset(scsi3addr, 0, 8);
-	scsi3addr[3] = tmpdevice->target;
-	if (is_hba_lunid(scsi3addr))
-		return 0; /* Don't add the RAID controller here. */
-
-	if (is_scsi_rev_5(h))
-		return 0; /* p1210m doesn't need to do this. */
-
-	if (*n_ext_target_devs >= MAX_EXT_TARGETS) {
-		dev_warn(&h->pdev->dev, "Maximum number of external "
-			"target devices exceeded.  Check your hardware "
-			"configuration.");
-		return 0;
-	}
-
-	if (hpsa_update_device_info(h, scsi3addr, this_device, NULL))
-		return 0;
-	(*n_ext_target_devs)++;
-	hpsa_set_bus_target_lun(this_device,
-				tmpdevice->bus, tmpdevice->target, 0);
-	hpsa_update_device_supports_aborts(h, this_device, scsi3addr);
-	set_bit(tmpdevice->target, lunzerobits);
-	return 1;
-}

 /*
  * Get address of physical disk used for an ioaccel2 mode command:
@@ -3951,20 +3897,6 @@
 		figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
 		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
 		this_device = currentsd[ncurrent];
-
-		/*
-		 * For external target devices, we have to insert a LUN 0 which
-		 * doesn't show up in CCISS_REPORT_PHYSICAL data, but there
-		 * is nonetheless an enclosure device there.  We have to
-		 * present that otherwise linux won't find anything if
-		 * there is no lun 0.
-		 */
-		if (add_ext_target_dev(h, tmpdevice, this_device,
-				lunaddrbytes, lunzerobits,
-				&n_ext_target_devs)) {
-			ncurrent++;
-			this_device = currentsd[ncurrent];
-		}

 		*this_device = *tmpdevice;
 		this_device->physical_device = physical_device;


remove the entry from the list, before freeing

--- mysys/mf_keycaches.c
+++ mysys/mf_keycaches.c
@@ -275,7 +275,11 @@
     if (entry->data == old_data)
     {
       if (new_data == hash->default_value)
+      {
+        if ((*entry->prev= entry->next))
+          entry->next->prev= entry->prev;
 	hash_delete(&hash->hash, (byte*) entry);
+      }
       else
 	entry->data= new_data;
     }


modules/fast: Fix bug in collection iteration.

--- modules/fast.c
+++ modules/fast.c
@@ -563,7 +563,7 @@

     for (
         const fast_collection_spec_t *collection = collections;
-        collection != NULL;
+        collection->name != NULL;
         ++collection
     ) {
         rc = fast_feed_data_collection(


[SCSI] hpsa: fix incorrect abort diagnostic message

In the abort handler, when asked to abort a command which
is not known to the driver, SUCCESS is returned, but the
diagnostic message incorrectly indicates the abort failed.

Signed-off-by: Stephen M. Cameron <fcc9df7f1d62c98ed1e7091f4fa112f895d521f5@beardog.cce.hp.com>
Signed-off-by: James Bottomley <1acebbdca565c7b6b638bdc23b58b5610d1a56b8@Parallels.com>

--- drivers/scsi/hpsa.c
+++ drivers/scsi/hpsa.c
@@ -2609,7 +2609,7 @@
 	/* not in reqQ, if also not in cmpQ, must have already completed */
 	found = hpsa_find_cmd_in_queue(h, sc, &h->cmpQ);
 	if (!found)  {
-		dev_dbg(&h->pdev->dev, "%s Request FAILED (not known to driver).\n",
+		dev_dbg(&h->pdev->dev, "%s Request SUCCEEDED (not known to driver).\n",
 				msg);
 		return SUCCESS;
 	}


modules/fast: Use REQUEST_URI_RAW instead of REQUEST_URI due to RNS-190.

--- modules/fast.c
+++ modules/fast.c
@@ -142,7 +142,8 @@
 /*! Bytestrings to feed during REQUEST_HEADER phase. */
 static const char *c_request_header_bytestrings[] = {
     "REQUEST_METHOD",
-    "REQUEST_URI",
+    // @todo: Change this to REQUESTURI when RNS-190 is fixed.
+    "REQUEST_URI_RAW",
     "REQUEST_PROTOCOL",
     NULL
 };


test/cunit/ofp_test_rt_mtrie_lookup: Initialize ODP.

In an upcoming patch, AVL tree will use ofp_brlock instead of
odp_rwlock. Since ofp_brlock calls odp_thread_id(), it's necessary to
call odp_init_local() before using an AVL tree.

The MTRIE implementation uses an AVL tree when adding or removing
routes, so make the unit test program call ODP initialization
functions before the test cases.

Signed-off-by: Jere Leppänen <14957520de8d9815e0c353a07fe23c737f0171e9@nokia.com>
Reviewed-by: Valentin Radulescu <5c0267d222138450b4835b40b746ecdf0117cfc8@enea.com>

--- test/cunit/ofp_test_rt_mtrie_lookup.c
+++ test/cunit/ofp_test_rt_mtrie_lookup.c
@@ -488,6 +488,11 @@

 int main(void)
 {
+	odp_instance_t instance;
+
+	odp_init_global(&instance, NULL, NULL);
+	odp_init_local(instance, ODP_THREAD_CONTROL);
+
 	if (CU_initialize_registry() != CUE_SUCCESS)
 		return CU_get_error();


[SCSI] hpsa: remove atrophied hpsa_scsi_setup function

hpsa_scsi_setup at one time contained enough code to justify
its existence, but that time has passed.

Signed-off-by: Stephen M. Cameron <fcc9df7f1d62c98ed1e7091f4fa112f895d521f5@beardog.cce.hp.com>
Signed-off-by: James Bottomley <91e2c378bdc9ac58358cd03ebb6c74f7db9aa049@parallels.com>
Signed-off-by: James Bottomley <407b36959ca09543ccda8f8e06721c791bc53435@suse.de>

--- drivers/scsi/hpsa.c
+++ drivers/scsi/hpsa.c
@@ -927,13 +927,6 @@
 static void hpsa_slave_destroy(struct scsi_device *sdev)
 {
 	/* nothing to do. */
-}
-
-static void hpsa_scsi_setup(struct ctlr_info *h)
-{
-	h->ndevices = 0;
-	h->scsi_host = NULL;
-	spin_lock_init(&h->devlock);
 }

 static void hpsa_free_sg_chain_blocks(struct ctlr_info *h)
@@ -3970,7 +3963,9 @@
 	h->scan_finished = 1; /* no scan currently in progress */

 	pci_set_drvdata(pdev, h);
-	hpsa_scsi_setup(h);
+	h->ndevices = 0;
+	h->scsi_host = NULL;
+	spin_lock_init(&h->devlock);

 	/* Turn the interrupts on so we can service requests */
 	h->access.set_intr_mask(h, HPSA_INTR_ON);


initialization fix to please valgrind

initialization fix to please valgrind

--- modules/ftbl.c
+++ modules/ftbl.c
@@ -84,6 +84,9 @@
         out = tokenize(&str, &size);
         if(ft->size < j + 1){
             ft->tbl = realloc(ft->tbl, sizeof(SPFLOAT) * (ft->size + 2));
+            /* zero out new tables */
+            ft->tbl[ft->size] = 0;
+            ft->tbl[ft->size + 1] = 0;
             ft->size++;
         }
         ft->tbl[j] = atof(out);


[SCSI] hpsa: do not reset unknown boards on reset_devices

This is to prevent hpsa from resetting older boards
which the cciss driver may be controlling.

Signed-off-by: Stephen M. Cameron <fcc9df7f1d62c98ed1e7091f4fa112f895d521f5@beardog.cce.hp.com>
Signed-off-by: James Bottomley <407b36959ca09543ccda8f8e06721c791bc53435@suse.de>

--- drivers/scsi/hpsa.c
+++ drivers/scsi/hpsa.c
@@ -3140,7 +3140,11 @@
 	 * likely not be happy.  Just forbid resetting this conjoined mess.
 	 * The 640x isn't really supported by hpsa anyway.
 	 */
-	hpsa_lookup_board_id(pdev, &board_id);
+	rc = hpsa_lookup_board_id(pdev, &board_id);
+	if (rc < 0) {
+		dev_warn(&pdev->dev, "Not resetting device.\n");
+		return -ENODEV;
+	}
 	if (board_id == 0x409C0E11 || board_id == 0x409D0E11)
 		return -ENOTSUPP;


Add float type alias

Add float type alias


minor correction to pragma reenable

minor correction to pragma reenable

--- src/NeuralNet.h
+++ src/NeuralNet.h
@@ -42,7 +42,7 @@
 #endif
     std::vector< Layer *> layers;
 #ifdef _WIN32
-#pragma warning( enable: 4251 )
+#pragma warning( restore: 4251 )
 #endif
     OpenCLHelper *cl;
 public:


Added Writer for outputting Stylesheets as text.

error: pathspec 'src/Writer.h' did not match any file(s) known to git

--- src/Writer.h
+++ src/Writer.h
@@ -0,0 +1,22 @@
+#ifndef __Writer_h__
+#define __Writer_h__
+
+#include "Stylesheet.h"
+#include <string>
+#include <vector>
+using namespace std;
+
+class Writer {
+public:
+  Writer(ostream* out);
+  void writeStylesheet(Stylesheet* s);
+
+private:
+  ostream* out;
+  void writeAtRule(AtRule* rule);
+  void writeRuleset(Ruleset* ruleset);
+  void writeDeclaration(Declaration* declaration);
+
+}
+
+#endif


Expose underlying devices of a ParallelDevice.

PiperOrigin-RevId: 367449422
Change-Id: I4bd604e9574ada803e9e549c2d99c56713719e54

--- tensorflow/c/eager/parallel_device/parallel_device_lib.h
+++ tensorflow/c/eager/parallel_device/parallel_device_lib.h
@@ -80,6 +80,11 @@

   // The number of devices operations run on.
   size_t num_underlying_devices() const { return underlying_devices_.size(); }
+
+  // The devices operations run on.
+  const std::vector<std::string>& underlying_devices() const {
+    return underlying_devices_;
+  }

   // Takes a description of a single operation being executed on the
   // ParallelDevice, and in turn runs one operation per component device with


hpsa: fix an sprintf() overflow in the reset handler

The string "cmd %d RESET FAILED, new lockup detected" is not quite
large enough so the sprintf() will overflow.  I have increased the size
of the buffer and also changed the sprintf calls to snprintf.

Fixes: 73153fe533bc ('hpsa: use block layer tag for command allocation')
Signed-off-by: Dan Carpenter <ff341aa343d564f9e53e9dcb6996be8c04859a66@oracle.com>
Acked-by: Don Brace <2492869e79b95109d0bee0fc4e8bb0141c1888c7@pmcs.com>
Signed-off-by: James Bottomley <1acebbdca565c7b6b638bdc23b58b5610d1a56b8@Odin.com>

--- drivers/scsi/hpsa.c
+++ drivers/scsi/hpsa.c
@@ -5104,7 +5104,7 @@
 	int rc;
 	struct ctlr_info *h;
 	struct hpsa_scsi_dev_t *dev;
-	char msg[40];
+	char msg[48];

 	/* find the controller to which the command to be aborted was sent */
 	h = sdev_to_hba(scsicmd->device);
@@ -5122,16 +5122,18 @@

 	/* if controller locked up, we can guarantee command won't complete */
 	if (lockup_detected(h)) {
-		sprintf(msg, "cmd %d RESET FAILED, lockup detected",
-				hpsa_get_cmd_index(scsicmd));
+		snprintf(msg, sizeof(msg),
+			 "cmd %d RESET FAILED, lockup detected",
+			 hpsa_get_cmd_index(scsicmd));
 		hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
 		return FAILED;
 	}

 	/* this reset request might be the result of a lockup; check */
 	if (detect_controller_lockup(h)) {
-		sprintf(msg, "cmd %d RESET FAILED, new lockup detected",
-				hpsa_get_cmd_index(scsicmd));
+		snprintf(msg, sizeof(msg),
+			 "cmd %d RESET FAILED, new lockup detected",
+			 hpsa_get_cmd_index(scsicmd));
 		hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
 		return FAILED;
 	}
@@ -5145,7 +5147,8 @@
 	/* send a reset to the SCSI LUN which the command was sent to */
 	rc = hpsa_do_reset(h, dev, dev->scsi3addr, HPSA_RESET_TYPE_LUN,
 			   DEFAULT_REPLY_QUEUE);
-	sprintf(msg, "reset %s", rc == 0 ? "completed successfully" : "failed");
+	snprintf(msg, sizeof(msg), "reset %s",
+		 rc == 0 ? "completed successfully" : "failed");
 	hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
 	return rc == 0 ? SUCCESS : FAILED;
 }


minor correction to pragma reenable

minor correction to pragma reenable

--- src/NeuralNet.h
+++ src/NeuralNet.h
@@ -38,11 +38,11 @@
 class DeepCL_EXPORT NeuralNet : public Trainable {
 protected:
 #ifdef _WIN32
-#pragma warning disable 4251
+#pragma warning( disable: 4251 )
 #endif
     std::vector< Layer *> layers;
 #ifdef _WIN32
-#pragma warning restore 4251
+#pragma warning( default: 4251 )
 #endif
     OpenCLHelper *cl;
 public:


[FIX] Compare home end stop to 0 for home detection

--- src/ZStage.h
+++ src/ZStage.h
@@ -169,7 +169,7 @@
   bool zstage_engaged_stop_enabled() const { return state_.engaged_stop_enabled; }

   bool zstage_at_home() {
-    return state_.home_stop_enabled && (analogRead(PIN_END_STOP_1) < (1023 / 4));
+    return state_.home_stop_enabled && (analogRead(PIN_END_STOP_1) == 0);
   }
 };