crypto/test: Fix incorrect type in mac_test()

- Fix incorrect array type for output buffer in mac_test()

Reported-by: Phil Nelson <e888d2bd6f13f82caa51a37c03d034c76f661ba3@cs.wwu.edu>

--- crypto/test/run_vectors.c
+++ crypto/test/run_vectors.c
@@ -350,7 +350,7 @@
 {
 	struct isrcry_mac_ctx *ctx;
 	const struct mac_test *test;
-	unsigned mac[64 + 1];
+	uint8_t mac[64 + 1];
 	unsigned n;
 	unsigned m;


Try to degrade gracefully if inotify is unavailable

--- vm/os-linux.c
+++ vm/os-linux.c
@@ -18,6 +18,8 @@
 	}
 }

+#ifdef SYS_inotify_init
+
 int inotify_init(void)
 {
 	return syscall(SYS_inotify_init);
@@ -32,3 +34,25 @@
 {
 	return syscall(SYS_inotify_rm_watch, fd, wd);
 }
+
+#else
+
+int inotify_init(void)
+{
+	not_implemented_error();
+	return -1;
+}
+
+int inotify_add_watch(int fd, const char *name, u32 mask)
+{
+	not_implemented_error();
+	return -1;
+}
+
+int inotify_rm_watch(int fd, u32 wd)
+{
+	not_implemented_error();
+	return -1;
+}
+
+#endif


app/test: no more builtin commands

app/test: no more builtin commands

The builtin commands list is now empty, we can remove it.

Signed-off-by: David Marchand <f28529695cfa9e3e1eb84e7072aa626af4abb18e@6wind.com>
Acked-by: Bruce Richardson <66b9e8e8fbd5e9f41f91b0af050876182ce9d0e4@intel.com>
Acked-by: Neil Horman <3316dc2d77df57653443c0391a5296176d6ca9c3@tuxdriver.com>

--- app/test/commands.c
+++ app/test/commands.c
@@ -324,9 +324,8 @@
 int commands_init(void)
 {
 	struct test_command *t;
-	char builtin_commands[] = "";
 	char *commands, *ptr;
-	int commands_len = strlen(builtin_commands) + 1;
+	int commands_len = 0;

 	TAILQ_FOREACH(t, &commands_list, next) {
 		commands_len += strlen(t->command) + 1;
@@ -340,7 +339,8 @@
 	TAILQ_FOREACH(t, &commands_list, next) {
 		ptr += sprintf(ptr, "%s#", t->command);
 	}
-	ptr += sprintf(ptr, "%s", builtin_commands);
+	ptr--;
+	ptr[0] = '\0';

 	cmd_autotest_autotest.string_data.str = commands;
 	return 0;


last bugs in C piecewise-parametric stat tracker fixed

--- faststat/_faststat.c
+++ faststat/_faststat.c
@@ -148,51 +148,34 @@
 //helper for _update_percentiles
 static void _p2_update_point(double l_v, double l_n, faststat_P2Percentile *cur,
                             double r_v, double r_n, unsigned int n) {
-    unsigned int d;
+    int d;
     double percentile, new_val, c_v, c_n, diff;
     percentile = ((double)cur->percentile) / 0x10000;
     c_n = cur->n;
     diff = (n - 1) * percentile + 1 - c_n;
-    //if(percentile > 0.9) printf("CALL%0.2f\n", percentile);
     // clamp d at +/- 1
     if(diff >= 1) {
-       // if(percentile > 0.9) printf("+");
         d = 1;
     } else if(diff <= -1) {
-       // if(percentile > 0.9) printf("-");
         d = -1;
     } else {
-     //   if(percentile > 0.9)
-     //   printf("#%0.3f %0.2f\n", diff, percentile);
         return;
     }
     c_v = cur->val;
     if(l_n < c_n + d && c_n + d < r_n) {  // try updating estimate with parabolic
-        //printf("\nL %0.3f %0.3f C %0.3f %0.3f R %0.3f %0.3f\n", l_v, l_n, c_v, c_n, r_v, r_n);
-        // NOTE: all this math must be floating point!  no ints allowed!
         new_val = c_v + (d / (r_n - l_n)) * (
             (c_n - l_n + d) * (r_v - c_v) / (r_n - c_n) +
             (r_n - c_n - d) * (c_v - l_v) / (c_n - l_n));
-        //if(new_val == c_v) {
-        //    printf("?");
-        //    printf("\nL %0.3f %0.3f C %0.3f %0.3f R %0.3f %0.3f\n", l_v, l_n, c_v, c_n, r_v, r_n);
-        //}
-        //printf("parabolic %0.3f\n", new_val);
         if(l_v >= new_val || r_v <= new_val) {  // fall back on linear
             if(d == 1) {
                 new_val = c_v + (r_v - c_v) / (r_n - c_n);
             } else {  // d == -1
                 new_val = c_v - (l_v - c_v) / (l_n - c_n);
             }
-            //printf("linear %0.3f", new_val);
-        }
-        //printf("updating %0.2f:  %0.2f to %0.2f (%d -> %d)\n",
-        //    percentile, cur->val, new_val, cur->n, cur->n+d);
+        }
         cur->val = new_val;
         cur->n += d;
-    } //else {
-    //    if(percentile > 0.9) printf("x");
-   // }
+    }
 }

@@ -208,10 +191,6 @@
         }
     }
     self->percentiles[num-1].val = x;
-    //for(i=0; i <= num-1; i++) {
-    //    printf("%0.1f ", self->percentiles[i].val);
-    //}
-    //printf("\n");
 }

@@ -229,8 +208,6 @@
     //right-most is stopping case; handle first
     if(x < right->val && right->n + 1 < self->n) {
         right->n++;
-        //printf("incrementing right; X %0.2f RV %0.2f RN %d SN %d",
-        //    x, right->val, right->n - 1, self->n);
     }
     //handle the rest of the points
     prev = right;
@@ -244,14 +221,11 @@
     //left-most point is a special case
     nxt = &(self->percentiles[1]);
     _p2_update_point(self->min, 0, left, nxt->val, nxt->n, self->n);
-
+    cur = left;
     for(i=1; i < self->num_percentiles - 1; i++) {
-        prev = &(self->percentiles[i-1]);
-        cur = &(self->percentiles[i]);
+        prev = cur;
+        cur = nxt;
         nxt = &(self->percentiles[i+1]);
-
-        //percentile = ((double)cur->percentile) / 0x10000;
-        //printf("/%0.2f", percentile);
         _p2_update_point(prev->val, prev->n, cur, nxt->val, nxt->n, self->n);
     }
     _p2_update_point(cur->val, cur->n, right, self->max, self->n, self->n);


Noformat the operations table

Noformat the operations table


Removed an unnecessary TODO

Removed an unnecessary TODO


Fix bogus error checking.

Fix bogus error checking.

--- audio/avdtp.c
+++ audio/avdtp.c
@@ -1510,11 +1510,6 @@

 	sk = g_io_channel_unix_get_fd(chan);

-	if (cond & (G_IO_ERR | G_IO_HUP)) {
-		err = EIO;
-		goto failed;
-	}
-
 	len = sizeof(ret);
 	if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &ret, &len) < 0) {
 		err = errno;
@@ -1525,6 +1520,11 @@
 	if (ret != 0) {
 		err = ret;
 		error("connect(): %s (%d)", strerror(err), err);
+		goto failed;
+	}
+
+	if (cond & G_IO_HUP) {
+		err = EIO;
 		goto failed;
 	}


from t_unix <- add none enum for randr

from t_unix <- add none enum for randr

SVN revision: 51387

--- src/lib/ecore_x/Ecore_X.h
+++ src/lib/ecore_x/Ecore_X.h
@@ -188,7 +188,8 @@
    ECORE_X_RANDR_OUTPUT_POLICY_RIGHT = 2,
    ECORE_X_RANDR_OUTPUT_POLICY_BELOW = 3,
    ECORE_X_RANDR_OUTPUT_POLICY_LEFT = 4,
-   ECORE_X_RANDR_OUTPUT_POLICY_CLONE = 5
+   ECORE_X_RANDR_OUTPUT_POLICY_CLONE = 5,
+   ECORE_X_RANDR_OUTPUT_POLICY_NONE = 6
 } Ecore_X_Randr_Output_Policy;

 typedef enum _Ecore_X_Randr_Relative_Alignment {


change UDP MTU size

change UDP MTU size

--- libs/vds_dht_network/private/dht_datagram_protocol.h
+++ libs/vds_dht_network/private/dht_datagram_protocol.h
@@ -116,7 +116,7 @@
             if(this->mtu_ < datagram.size()) {
               this->mtu_ = datagram.size();
               this->check_mtu_ = 0;
-              this->sp_->get<logger>()->trace("dht_session", "Change MTU size to %d", this->mtu_);
+              logger::get(this->sp_)->trace("dht_session", "Change MTU size to %d", this->mtu_);
             }
             co_return;
           }


Eina: more doc

Eina: more doc

SVN revision: 69813

--- src/lib/eina_file_win32.c
+++ src/lib/eina_file_win32.c
@@ -1172,7 +1172,34 @@
 eina_file_map_faulted(Eina_File *file, void *map)
 {
   /*
-   * FIXME: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366801%28v=vs.85%29.aspx
+   * FIXME:
+   * vc++ : http://msdn.microsoft.com/en-us/library/windows/desktop/aa366801%28v=vs.85%29.aspx
+   *
+   * mingw-w64 :
+   * - 32 bits : there is a way to implement __try/__except/__final in C.
+   *   see excpt.h header for 32-bits
+   * - 64 bits : some inline assembly required for it.  See as example our
+   *   startup-code in WinMainCRTStartup() in crtexe.c :
+{
+  int ret = 255;
+#ifdef __SEH__
+  asm ("\t.l_startw:\n"
+    "\t.seh_handler __C_specific_handler, @except\n"
+    "\t.seh_handlerdata\n"
+    "\t.long 1\n"
+    "\t.rva .l_startw, .l_endw, _gnu_exception_handler ,.l_endw\n"
+    "\t.text"
+    );
+#endif
+  mingw_app_type = 1;
+  __security_init_cookie ();
+  ret = __tmainCRTStartup ();
+#ifdef __SEH__
+  asm ("\tnop\n"
+    "\t.l_endw: nop\n");
+#endif
+  return ret;
+}
    */
    return EINA_FALSE;
 }


elm_progressbar.c: adopted ELM_WIDGET_DATA_GET_OR_RETURN macro.

--- src/lib/elm_progressbar.c
+++ src/lib/elm_progressbar.c
@@ -86,7 +86,7 @@
    double pos;

    ELM_PROGRESSBAR_DATA_GET(obj, sd);
-   Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS);
+   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);

    rtl = elm_widget_mirrored_get(obj);
    Elm_Progress_Status *ps;
@@ -109,8 +109,7 @@
 _elm_progressbar_smart_sizing_eval(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
 {
    Evas_Coord minw = -1, minh = -1;
-
-   Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS);
+   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);

    edje_object_size_min_restricted_calc
      (wd->resize_obj, &minw, &minh, minw, minh);
@@ -178,7 +177,7 @@
    if (ret) *ret = EINA_FALSE;
    Eina_Bool int_ret = EINA_FALSE;
    Elm_Layout_Smart_Data *ld = eo_data_scope_get(obj, ELM_OBJ_LAYOUT_CLASS);
-   Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS);
+   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);

    if (sd->horizontal)
      eina_stringshare_replace(&ld->group, "horizontal");
@@ -264,7 +263,7 @@
 _elm_progressbar_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
 {
    Elm_Progressbar_Smart_Data *priv = _pd;
-   Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS);
+   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);

    eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
    elm_widget_sub_object_parent_add(obj);
@@ -595,7 +594,7 @@
 {
    const char *units = va_arg(*list, const char *);
    Elm_Progressbar_Smart_Data *sd = _pd;
-   Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS);
+   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);

    eina_stringshare_replace(&sd->units, units);
    if (units)
@@ -703,7 +702,7 @@
 {
    Eina_Bool inverted = va_arg(*list, int);
    Elm_Progressbar_Smart_Data*sd = _pd;
-   Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS);
+   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);

    inverted = !!inverted;
    if (sd->inverted == inverted) return;


release

release

--- DWCoreTextLabel/DWCoreTextLabel/DWCoreTextLabel.h
+++ DWCoreTextLabel/DWCoreTextLabel/DWCoreTextLabel.h
@@ -109,6 +109,7 @@

  version 1.1.5
  添加网络图片现在库，支持绘制网络图片。
+
  */

 #import <UIKit/UIKit.h>


static_image.h robust to being compiled with c++11

--- apps/support/static_image.h
+++ apps/support/static_image.h
@@ -9,9 +9,15 @@
 #include <stdint.h>
 #include <memory>
 #include <limits>
+#include <stdlib.h>

+#if __cplusplus > 199711L
+#include <memory>
+using std::shared_ptr;
+#else
 #include <tr1/memory>
 using std::tr1::shared_ptr;
+#endif

 #ifndef BUFFER_T_DEFINED
 #define BUFFER_T_DEFINED


iostream-rawlog: Don't assert-crash if trying to write 0 bytes.

--- src/lib/iostream-rawlog.c
+++ src/lib/iostream-rawlog.c
@@ -95,7 +95,8 @@
 	size_t pos;
 	bool line_ends;

-	i_assert(size > 0);
+	if (size == 0)
+		return;

 	io_loop_time_refresh();
 	if ((rstream->flags & IOSTREAM_RAWLOG_FLAG_BUFFERED) == 0) {


fix build with msvc

fix build with msvc

--- src/lib/libwpd_internal.h
+++ src/lib/libwpd_internal.h
@@ -30,6 +30,7 @@
 #include <string>
 #include <algorithm>
 #include "WPXString.h"
+#include "libwpd_types.h"

 /* Various functions/defines that need not/should not be exported externally */


The consumer for smbios recorder should *not* make assumption the SMBIOS structure in special version. For length of smbios record, consumer need judge the SMBIOS->Hdr.Length but not use size of (SMBIOS_TYPE0) style.

git-svn-id: 5648d1bec6962b0a6d1d1b40eba8cf5cdb62da3d@9553 6f19259b-4bc3-4df7-8a09-765794883524

--- IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
+++ IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
@@ -749,7 +749,7 @@
     if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {
       Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;
       StrIndex = Type0Record->BiosVersion;
-      GetOptionalStringByIndex ((CHAR8*)(Type0Record+1), StrIndex, &NewString);
+      GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length + 1), StrIndex, &NewString);
       TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);
       HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
       FreePool (NewString);
@@ -759,7 +759,7 @@
     if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) {
       Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;
       StrIndex = Type1Record->ProductName;
-      GetOptionalStringByIndex ((CHAR8*)(Type1Record+1), StrIndex, &NewString);
+      GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length + 1), StrIndex, &NewString);
       TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);
       HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
       FreePool (NewString);
@@ -769,7 +769,7 @@
     if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {
       Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;
       StrIndex = Type4Record->ProcessorVersion;
-      GetOptionalStringByIndex ((CHAR8*)(Type4Record+1), StrIndex, &NewString);
+      GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length + 1), StrIndex, &NewString);
       TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL);
       HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
       FreePool (NewString);


The "mine-conflict" and "their-conflict" options are rarely more appropriate
than "edit" and "merge". Don't encourage gratuitous use of them by not showing
them at the initial conflict prompt. They're still visible in the help menu.

* subversion/svn/conflict-callbacks.c
  (builtin_resolver_options): Drop the short descriptions for "mc", "tc",
   "mf", and "tf" options. The help menu shows better long descriptions.
  (handle_text_conflict): Don't add "mc" and "tc" to the initial list of
   suggested options.

git-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@1740159 13f79535-47bb-0310-9956-ffa450edef68


remove dead code

remove dead code

Obtained from:	netbsd


More refined debugging.

More refined debugging.

--- handler/SQLBuildDATA.h
+++ handler/SQLBuildDATA.h
@@ -360,7 +360,9 @@
                     type_factory, error_factory);

             if (bt) { // if 'bt' is created
-                BESDEBUG(SQL_NAME, "SQLBuildDATA: next object is ready"<<endl);
+                BESDEBUG(SQL_NAME, "SQLBuildDATA: The " << bt->type_name() <<
+                        (bt->is_vector_type()?" array":" instance" )<< " named '"<< bt->name() <<
+                        "'  is ready, adding..."<<endl);
                 // FIXME connector->getColDesc(i) is not the correct type value for
                 // most of the variables.
                 attr.append_attr(bt->name(), bt->type_name(), connector->getColDesc(i));
@@ -403,7 +405,7 @@
         connector->reset();

         if (seq) {
-            BESDEBUG(SQL_NAME, "SQLBuildDATA: Adding variable to dds"<<endl);
+            BESDEBUG(SQL_NAME, "SQLBuildDATA: Adding SQLSequence variable '" << seq->name() << "' to DDS"<<endl);
             dds->add_var_nocopy(seq);
 #if 0
             /** ONLY VALID FOR AUTO_PTR
@@ -417,7 +419,6 @@
             // switched to _nocopy() above. 9/10/12 jhrg
             delete seq;//safe
 #endif
-            BESDEBUG(SQL_NAME, "SQLBuildDATA: set dataset name"<<endl);
             // The BES is setting this to 'virtual'. This is a better
             // name because it is consistent with how other responses
             // are named. 9/10/12 jhrg
@@ -426,6 +427,7 @@
             if (p != string::npos && p+1 <= name.length())
                 name = name.substr(p + 1);
             dds->set_dataset_name(name);
+            BESDEBUG(SQL_NAME, "SQLBuildDATA: Set dataset name to: '"<< name << "'" <<endl);
 #if 0
             // Not needed. This is set by the BES (tucked away in dapreader)
             // in DapRequestHandler::dap_build_dds jhrg 9/10/12


lib-fs: fs-metawrap now supports adding more metadata fields while file is being saved. This potentially adds yet another temporary file write though.

--- src/lib-fs/fs-metawrap.c
+++ src/lib-fs/fs-metawrap.c
@@ -6,9 +6,11 @@
 #include "strescape.h"
 #include "istream.h"
 #include "istream-private.h"
+#include "istream-concat.h"
 #include "istream-metawrap.h"
 #include "ostream.h"
 #include "ostream-metawrap.h"
+#include "iostream-temp.h"
 #include "fs-api-private.h"

 #define MAX_METADATA_LINE_LEN 8192
@@ -24,8 +26,13 @@
 	struct fs_file *super, *super_read;
 	enum fs_open_mode open_mode;
 	struct istream *input;
+	bool metadata_read;
+
 	struct ostream *super_output;
-	bool metadata_read;
+	struct ostream *temp_output;
+	string_t *metadata_header;
+	uoff_t metadata_write_size;
+	bool metadata_changed_since_write;
 };

 struct metawrap_fs_iter {
@@ -132,6 +139,8 @@

 	if (file->super_read != file->super && file->super_read != NULL)
 		fs_file_deinit(&file->super_read);
+	if (file->metadata_header != NULL)
+		str_free(&file->metadata_header);
 	fs_file_deinit(&file->super);
 	i_free(file->file.path);
 	i_free(file);
@@ -179,8 +188,10 @@

 	if (!file->fs->wrap_metadata)
 		fs_set_metadata(file->super, key, value);
-	else
+	else {
 		fs_default_set_metadata(_file, key, value);
+		file->metadata_changed_since_write = TRUE;
+	}
 }

 static int
@@ -269,15 +280,11 @@
 	return fs_write_via_stream(_file, data, size);
 }

-static void fs_metawrap_write_metadata(void *context)
-{
-	struct metawrap_fs_file *file = context;
+static void
+fs_metawrap_append_metadata(struct metawrap_fs_file *file, string_t *str)
+{
 	const struct fs_metadata *metadata;
-	string_t *str = t_str_new(256);
-	ssize_t ret;
-
-	/* FIXME: if fs_set_metadata() is called later the changes are
-	   ignored. we'd need to write via temporary file then. */
+
 	array_foreach(&file->file.metadata, metadata) {
 		str_append_tabescaped(str, metadata->key);
 		str_append_c(str, ':');
@@ -285,11 +292,23 @@
 		str_append_c(str, '\n');
 	}
 	str_append_c(str, '\n');
+}
+
+static void fs_metawrap_write_metadata(void *context)
+{
+	struct metawrap_fs_file *file = context;
+	string_t *str = t_str_new(256);
+	ssize_t ret;
+
+	fs_metawrap_append_metadata(file, str);
+	file->metadata_write_size = str_len(str);
+
 	ret = o_stream_send(file->file.output, str_data(str), str_len(str));
 	if (ret < 0)
 		o_stream_close(file->file.output);
 	else
 		i_assert((size_t)ret == str_len(str));
+	file->metadata_changed_since_write = FALSE;
 }

 static void fs_metawrap_write_stream(struct fs_file *_file)
@@ -298,18 +317,46 @@

 	i_assert(_file->output == NULL);

-	file->super_output = fs_write_stream(file->super);
-	if (!file->fs->wrap_metadata)
+	if (!file->fs->wrap_metadata) {
+		file->super_output = fs_write_stream(file->super);
 		_file->output = file->super_output;
-	else {
-		_file->output = o_stream_create_metawrap(file->super_output,
+	} else {
+		file->temp_output =
+			iostream_temp_create_named(_file->fs->temp_path_prefix,
+						   IOSTREAM_TEMP_FLAG_TRY_FD_DUP,
+						   fs_file_path(_file));
+		_file->output = o_stream_create_metawrap(file->temp_output,
 			fs_metawrap_write_metadata, file);
 	}
 }

+static struct istream *
+fs_metawrap_create_updated_istream(struct metawrap_fs_file *file,
+				   struct istream *input)
+{
+	struct istream *input2, *inputs[3];
+
+	if (file->metadata_header != NULL)
+		str_truncate(file->metadata_header, 0);
+	else
+		file->metadata_header = str_new(default_pool, 1024);
+	fs_metawrap_append_metadata(file, file->metadata_header);
+	inputs[0] = i_stream_create_from_data(str_data(file->metadata_header),
+					       str_len(file->metadata_header));
+
+	i_stream_seek(input, file->metadata_write_size);
+	inputs[1] = i_stream_create_limit(input, (uoff_t)-1);
+	inputs[2] = NULL;
+	input2 = i_stream_create_concat(inputs);
+	i_stream_unref(&inputs[0]);
+	i_stream_unref(&inputs[1]);
+	return input2;
+}
+
 static int fs_metawrap_write_stream_finish(struct fs_file *_file, bool success)
 {
 	struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
+	struct istream *input;
 	int ret;

 	if (_file->output != NULL) {
@@ -320,13 +367,53 @@
 		else
 			o_stream_unref(&_file->output);
 	}
-
 	if (!success) {
+		if (file->temp_output != NULL)
+			o_stream_destroy(&file->temp_output);
+		if (file->super_output != NULL)
+			fs_write_stream_abort(file->super, &file->super_output);
+		return -1;
+	}
+
+	if (file->super_output != NULL) {
+		/* no metawrap */
+		i_assert(file->temp_output == NULL);
+		return fs_write_stream_finish(file->super, &file->super_output);
+	}
+	if (file->temp_output == NULL) {
+		/* finishing up */
+		i_assert(file->super_output == NULL);
+		return fs_write_stream_finish(file->super, &file->super_output);
+	}
+	/* finish writing the temporary file */
+	input = iostream_temp_finish(&file->temp_output, IO_BLOCK_SIZE);
+	if (file->metadata_changed_since_write) {
+		/* we'll need to recreate the metadata. do this by creating a
+		   new istream combining the new metadata header and the
+		   old body. */
+		struct istream *input2 = input;
+
+		input = fs_metawrap_create_updated_istream(file, input);
+		i_stream_unref(&input2);
+	}
+	file->super_output = fs_write_stream(file->super);
+	if (o_stream_send_istream(file->super_output, input) >= 0)
+		ret = fs_write_stream_finish(file->super, &file->super_output);
+	else if (input->stream_errno != 0) {
+		fs_set_error(_file->fs, "read(%s) failed: %s",
+			     i_stream_get_name(input),
+			     i_stream_get_error(input));
 		fs_write_stream_abort(file->super, &file->super_output);
 		ret = -1;
 	} else {
-		ret = fs_write_stream_finish(file->super, &file->super_output);
-	}
+		i_assert(file->super_output->stream_errno != 0);
+		fs_set_error(_file->fs, "write(%s) failed: %s",
+			     o_stream_get_name(file->super_output),
+			     o_stream_get_error(file->super_output));
+		fs_write_stream_abort(file->super, &file->super_output);
+		ret = -1;
+	}
+	i_stream_unref(&input);
 	return ret;
 }


restrict_access(): If privileged and primary GIDs are the same, ignore privileged GID.

--- src/lib/restrict-access.c
+++ src/lib/restrict-access.c
@@ -267,6 +267,10 @@
 	/* set the primary/privileged group */
 	process_primary_gid = set->gid;
 	process_privileged_gid = set->privileged_gid;
+	if (process_privileged_gid == process_primary_gid) {
+		/* a pointless configuration, ignore it */
+		process_privileged_gid = (gid_t)-1;
+	}

 	have_root_group = process_primary_gid == 0;
 	if (process_primary_gid != (gid_t)-1 ||


Don't optimize the processing of the last rows of a matrix matrix product in cases that violate the assumptions made by the optimized code path.

--- Eigen/src/Core/products/GeneralBlockPanelKernel.h
+++ Eigen/src/Core/products/GeneralBlockPanelKernel.h
@@ -1625,9 +1625,14 @@
           prefetch(&blA[0]);
           const RhsScalar* blB = &blockB[j2*strideB+offsetB*nr];

-          if( (SwappedTraits::LhsProgress % 4)==0 )
+          // The following piece of code wont work for 512 bit registers
+          // Moreover it assumes that there is a half packet of the same size
+          // as nr (which is currently 4) for the return type.
+          typedef typename unpacket_traits<SResPacket>::half SResPacketHalf;
+          if ((SwappedTraits::LhsProgress % 4) == 0 &&
+              (SwappedTraits::LhsProgress <= 8) &&
+              unpacket_traits<SResPacketHalf>::size==4)
           {
-            // NOTE The following piece of code wont work for 512 bit registers
             SAccPacket C0, C1, C2, C3;
             straits.initAcc(C0);
             straits.initAcc(C1);


Get rid of some excess from task launcher

--- src/tasks/task_launcher.c
+++ src/tasks/task_launcher.c
@@ -18,21 +18,18 @@
 inline static void print_help() {
     vt_log("\n\t"
            "1 ~ K3 assignent demo\n\t"
-	   "2 ~ Create a suicidal task\n\t"
 	   "3 ~ Benchmark message passing\n\t"
-	   "4 ~ Get the current time\n\t"
-	   "5 ~ DelayUntil time + 100\n\t"
-	   "6 ~ Delay 100 ticks\n\t"
-	   "7 ~ Delay -100 ticks\n\t"
-	   "8 ~ DelayUntil time = 0\n\n\t"
+	   "4 ~ Get the current time\n\t");

-           "s ~ Run Stressing Task\n\n\t"
+    vt_log("\t"
+	   "s ~ Run Stressing Task\n\t");

-	   "i ~ Print the interrupt table status\n\t"
+    vt_log("\t"
 	   "a ~ Trigger software interrupt 0\n\t"
 	   "z ~ Trigger software interrupt 1\n\t"
-           "w ~ Trigger software interrupt 63\n\n\t"
+           "w ~ Trigger software interrupt 63\n\t");

+    vt_log("\t"
 	   "h ~ Print this Help Message\n\t"
 	   "q ~ Quit\n");

@@ -44,29 +41,11 @@
     case '1':
         Create(16, k3_root);
         break;
-    case '2':
-        vt_log("%d", Create(TASK_PRIORITY_MAX, seppuku));
-	break;
     case '3':
         Create(TASK_PRIORITY_MAX, bench_msg);
 	break;
     case '4':
 	vt_log("The time is %u ticks!", Time());
-	break;
-    case '5':
-	DelayUntil(Time() + 100);
-	break;
-    case '6':
-	Delay(100);
-	break;
-    case '7':
-	Delay(-100);
-	break;
-    case '8':
-	DelayUntil(0);
-	break;
-    case 'i':
-	debug_interrupt_table();
 	break;
     case 'a':
 	irq_simulate_interrupt(0);


Fixed a typo.

Fixed a typo.

--- Eigen/src/Core/products/GeneralBlockPanelKernel.h
+++ Eigen/src/Core/products/GeneralBlockPanelKernel.h
@@ -75,8 +75,8 @@
         if(nr==4) C7 = ei_ploadu(&res[(j2+3)*resStride + i + PacketSize]);

         // performs "inner" product
-        // TODO let's check wether the flowing peeled loop could not be
-        //      optimized via optimal prefetching from one loop to the other
+        // TODO let's check whether the flowing peeled loop could not be
+        //      optimized via optimal pre-fetching from one loop to the other
         const Scalar* blB = &blockB[j2*strideB*PacketSize+offsetB*nr];
         for(int k=0; k<peeled_kc; k+=4)
         {
@@ -184,6 +184,7 @@
             if(nr==4) { CJMADD(A1,B2,C6,T1); }
             if(nr==4) { CJMADD(A0,B3,C3,T0); }
             if(nr==4) { CJMADD(A1,B3,C7,T1); }
+
           }

           blB += 4*nr*PacketSize;


efreet: remove strdup, use alloca

efreet: remove strdup, use alloca

git-svn-id: 73370f4beb622e00b1e5fc4f999aefcb9ce2f227@47661 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/efreet_desktop.c
+++ src/lib/efreet_desktop.c
@@ -993,10 +993,13 @@
     Eina_List *list = NULL;
     char *tmp;
     char *s, *p;
+    size_t len;

     if (!string) return NULL;

-    tmp = strdup(string);
+    len = strlen(string) + 1;
+    tmp = alloca(len);
+    memcpy(tmp, string, len);
     s = tmp;

     while ((p = strchr(s, ';')))
@@ -1015,8 +1018,6 @@
 #endif
         list = eina_list_append(list, (void *)eina_stringshare_add(s));
     }
-
-    free(tmp);

     return list;
 }


GUACAMOLE-662: Properly initialize nested socket index (fixes GUACAMOLE-510).

--- src/libguac/socket-nest.c
+++ src/libguac/socket-nest.c
@@ -129,8 +129,9 @@
     guac_socket* socket = guac_socket_alloc();
     __guac_socket_nest_data* data = malloc(sizeof(__guac_socket_nest_data));

-    /* Store file descriptor as socket data */
+    /* Store nested socket details as socket data */
     data->parent = parent;
+    data->index = index;
     socket->data = data;

     /* Set write and free handlers */


Break out WebRtcNs_UpdateNoise function in ns_core

This is done in order to make the code more readible and maintainable.
It generates bit-exact output.

BUG=webrtc:3811
R=bjornv@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/25889004

Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: f8ea0d551895f1fea53bb80607804f0475e04244

--- modules/audio_processing/ns/ns_core.c
+++ modules/audio_processing/ns/ns_core.c
@@ -324,7 +324,7 @@
 // flag 0 means update histogram only, flag 1 means compute the
 // thresholds/weights
 // threshold and weights are returned in: inst->priorModelPars
-void WebRtcNs_FeatureParameterExtraction(NSinst_t* inst, int flag) {
+static void FeatureParameterExtraction(NSinst_t* const self, int flag) {
   int i, useFeatureSpecFlat, useFeatureSpecDiff, numHistLrt;
   int maxPeak1, maxPeak2;
   int weightPeak1SpecFlat, weightPeak2SpecFlat, weightPeak1SpecDiff,
@@ -335,74 +335,74 @@
   float fluctLrt, avgHistLrt, avgSquareHistLrt, avgHistLrtCompl;

   // 3 features: lrt, flatness, difference
-  // lrt_feature = inst->featureData[3];
-  // flat_feature = inst->featureData[0];
-  // diff_feature = inst->featureData[4];
+  // lrt_feature = self->featureData[3];
+  // flat_feature = self->featureData[0];
+  // diff_feature = self->featureData[4];

   // update histograms
   if (flag == 0) {
     // LRT
-    if ((inst->featureData[3] <
-         HIST_PAR_EST * inst->featureExtractionParams.binSizeLrt) &&
-        (inst->featureData[3] >= 0.0)) {
-      i = (int)(inst->featureData[3] /
-                inst->featureExtractionParams.binSizeLrt);
-      inst->histLrt[i]++;
+    if ((self->featureData[3] <
+         HIST_PAR_EST * self->featureExtractionParams.binSizeLrt) &&
+        (self->featureData[3] >= 0.0)) {
+      i = (int)(self->featureData[3] /
+                self->featureExtractionParams.binSizeLrt);
+      self->histLrt[i]++;
     }
     // Spectral flatness
-    if ((inst->featureData[0] <
-         HIST_PAR_EST * inst->featureExtractionParams.binSizeSpecFlat) &&
-        (inst->featureData[0] >= 0.0)) {
-      i = (int)(inst->featureData[0] /
-                inst->featureExtractionParams.binSizeSpecFlat);
-      inst->histSpecFlat[i]++;
+    if ((self->featureData[0] <
+         HIST_PAR_EST * self->featureExtractionParams.binSizeSpecFlat) &&
+        (self->featureData[0] >= 0.0)) {
+      i = (int)(self->featureData[0] /
+                self->featureExtractionParams.binSizeSpecFlat);
+      self->histSpecFlat[i]++;
     }
     // Spectral difference
-    if ((inst->featureData[4] <
-         HIST_PAR_EST * inst->featureExtractionParams.binSizeSpecDiff) &&
-        (inst->featureData[4] >= 0.0)) {
-      i = (int)(inst->featureData[4] /
-                inst->featureExtractionParams.binSizeSpecDiff);
-      inst->histSpecDiff[i]++;
+    if ((self->featureData[4] <
+         HIST_PAR_EST * self->featureExtractionParams.binSizeSpecDiff) &&
+        (self->featureData[4] >= 0.0)) {
+      i = (int)(self->featureData[4] /
+                self->featureExtractionParams.binSizeSpecDiff);
+      self->histSpecDiff[i]++;
     }
   }

   // extract parameters for speech/noise probability
   if (flag == 1) {
     // lrt feature: compute the average over
-    // inst->featureExtractionParams.rangeAvgHistLrt
+    // self->featureExtractionParams.rangeAvgHistLrt
     avgHistLrt = 0.0;
     avgHistLrtCompl = 0.0;
     avgSquareHistLrt = 0.0;
     numHistLrt = 0;
     for (i = 0; i < HIST_PAR_EST; i++) {
-      binMid = ((float)i + 0.5f) * inst->featureExtractionParams.binSizeLrt;
-      if (binMid <= inst->featureExtractionParams.rangeAvgHistLrt) {
-        avgHistLrt += inst->histLrt[i] * binMid;
-        numHistLrt += inst->histLrt[i];
-      }
-      avgSquareHistLrt += inst->histLrt[i] * binMid * binMid;
-      avgHistLrtCompl += inst->histLrt[i] * binMid;
+      binMid = ((float)i + 0.5f) * self->featureExtractionParams.binSizeLrt;
+      if (binMid <= self->featureExtractionParams.rangeAvgHistLrt) {
+        avgHistLrt += self->histLrt[i] * binMid;
+        numHistLrt += self->histLrt[i];
+      }
+      avgSquareHistLrt += self->histLrt[i] * binMid * binMid;
+      avgHistLrtCompl += self->histLrt[i] * binMid;
     }
     if (numHistLrt > 0) {
       avgHistLrt = avgHistLrt / ((float)numHistLrt);
     }
-    avgHistLrtCompl = avgHistLrtCompl / ((float)inst->modelUpdatePars[1]);
-    avgSquareHistLrt = avgSquareHistLrt / ((float)inst->modelUpdatePars[1]);
+    avgHistLrtCompl = avgHistLrtCompl / ((float)self->modelUpdatePars[1]);
+    avgSquareHistLrt = avgSquareHistLrt / ((float)self->modelUpdatePars[1]);
     fluctLrt = avgSquareHistLrt - avgHistLrt * avgHistLrtCompl;
     // get threshold for lrt feature:
-    if (fluctLrt < inst->featureExtractionParams.thresFluctLrt) {
+    if (fluctLrt < self->featureExtractionParams.thresFluctLrt) {
       // very low fluct, so likely noise
-      inst->priorModelPars[0] = inst->featureExtractionParams.maxLrt;
+      self->priorModelPars[0] = self->featureExtractionParams.maxLrt;
     } else {
-      inst->priorModelPars[0] =
-          inst->featureExtractionParams.factor1ModelPars * avgHistLrt;
+      self->priorModelPars[0] =
+          self->featureExtractionParams.factor1ModelPars * avgHistLrt;
       // check if value is within min/max range
-      if (inst->priorModelPars[0] < inst->featureExtractionParams.minLrt) {
-        inst->priorModelPars[0] = inst->featureExtractionParams.minLrt;
-      }
-      if (inst->priorModelPars[0] > inst->featureExtractionParams.maxLrt) {
-        inst->priorModelPars[0] = inst->featureExtractionParams.maxLrt;
+      if (self->priorModelPars[0] < self->featureExtractionParams.minLrt) {
+        self->priorModelPars[0] = self->featureExtractionParams.minLrt;
+      }
+      if (self->priorModelPars[0] > self->featureExtractionParams.maxLrt) {
+        self->priorModelPars[0] = self->featureExtractionParams.maxLrt;
       }
     }
     // done with lrt feature
@@ -419,20 +419,20 @@
     // peaks for flatness
     for (i = 0; i < HIST_PAR_EST; i++) {
       binMid =
-          (i + 0.5f) * inst->featureExtractionParams.binSizeSpecFlat;
-      if (inst->histSpecFlat[i] > maxPeak1) {
+          (i + 0.5f) * self->featureExtractionParams.binSizeSpecFlat;
+      if (self->histSpecFlat[i] > maxPeak1) {
         // Found new "first" peak
         maxPeak2 = maxPeak1;
         weightPeak2SpecFlat = weightPeak1SpecFlat;
         posPeak2SpecFlat = posPeak1SpecFlat;

-        maxPeak1 = inst->histSpecFlat[i];
-        weightPeak1SpecFlat = inst->histSpecFlat[i];
+        maxPeak1 = self->histSpecFlat[i];
+        weightPeak1SpecFlat = self->histSpecFlat[i];
         posPeak1SpecFlat = binMid;
-      } else if (inst->histSpecFlat[i] > maxPeak2) {
+      } else if (self->histSpecFlat[i] > maxPeak2) {
         // Found new "second" peak
-        maxPeak2 = inst->histSpecFlat[i];
-        weightPeak2SpecFlat = inst->histSpecFlat[i];
+        maxPeak2 = self->histSpecFlat[i];
+        weightPeak2SpecFlat = self->histSpecFlat[i];
         posPeak2SpecFlat = binMid;
       }
     }
@@ -447,20 +447,20 @@
     // peaks for spectral difference
     for (i = 0; i < HIST_PAR_EST; i++) {
       binMid =
-          ((float)i + 0.5f) * inst->featureExtractionParams.binSizeSpecDiff;
-      if (inst->histSpecDiff[i] > maxPeak1) {
+          ((float)i + 0.5f) * self->featureExtractionParams.binSizeSpecDiff;
+      if (self->histSpecDiff[i] > maxPeak1) {
         // Found new "first" peak
         maxPeak2 = maxPeak1;
         weightPeak2SpecDiff = weightPeak1SpecDiff;
         posPeak2SpecDiff = posPeak1SpecDiff;

-        maxPeak1 = inst->histSpecDiff[i];
-        weightPeak1SpecDiff = inst->histSpecDiff[i];
+        maxPeak1 = self->histSpecDiff[i];
+        weightPeak1SpecDiff = self->histSpecDiff[i];
         posPeak1SpecDiff = binMid;
-      } else if (inst->histSpecDiff[i] > maxPeak2) {
+      } else if (self->histSpecDiff[i] > maxPeak2) {
         // Found new "second" peak
-        maxPeak2 = inst->histSpecDiff[i];
-        weightPeak2SpecDiff = inst->histSpecDiff[i];
+        maxPeak2 = self->histSpecDiff[i];
+        weightPeak2SpecDiff = self->histSpecDiff[i];
         posPeak2SpecDiff = binMid;
       }
     }
@@ -469,30 +469,30 @@
     useFeatureSpecFlat = 1;
     // merge the two peaks if they are close
     if ((fabs(posPeak2SpecFlat - posPeak1SpecFlat) <
-         inst->featureExtractionParams.limitPeakSpacingSpecFlat) &&
+         self->featureExtractionParams.limitPeakSpacingSpecFlat) &&
         (weightPeak2SpecFlat >
-         inst->featureExtractionParams.limitPeakWeightsSpecFlat *
+         self->featureExtractionParams.limitPeakWeightsSpecFlat *
              weightPeak1SpecFlat)) {
       weightPeak1SpecFlat += weightPeak2SpecFlat;
       posPeak1SpecFlat = 0.5f * (posPeak1SpecFlat + posPeak2SpecFlat);
     }
     // reject if weight of peaks is not large enough, or peak value too small
     if (weightPeak1SpecFlat <
-            inst->featureExtractionParams.thresWeightSpecFlat ||
-        posPeak1SpecFlat < inst->featureExtractionParams.thresPosSpecFlat) {
+            self->featureExtractionParams.thresWeightSpecFlat ||
+        posPeak1SpecFlat < self->featureExtractionParams.thresPosSpecFlat) {
       useFeatureSpecFlat = 0;
     }
     // if selected, get the threshold
     if (useFeatureSpecFlat == 1) {
       // compute the threshold
-      inst->priorModelPars[1] =
-          inst->featureExtractionParams.factor2ModelPars * posPeak1SpecFlat;
+      self->priorModelPars[1] =
+          self->featureExtractionParams.factor2ModelPars * posPeak1SpecFlat;
       // check if value is within min/max range
-      if (inst->priorModelPars[1] < inst->featureExtractionParams.minSpecFlat) {
-        inst->priorModelPars[1] = inst->featureExtractionParams.minSpecFlat;
-      }
-      if (inst->priorModelPars[1] > inst->featureExtractionParams.maxSpecFlat) {
-        inst->priorModelPars[1] = inst->featureExtractionParams.maxSpecFlat;
+      if (self->priorModelPars[1] < self->featureExtractionParams.minSpecFlat) {
+        self->priorModelPars[1] = self->featureExtractionParams.minSpecFlat;
+      }
+      if (self->priorModelPars[1] > self->featureExtractionParams.maxSpecFlat) {
+        self->priorModelPars[1] = self->featureExtractionParams.maxSpecFlat;
       }
     }
     // done with flatness feature
@@ -501,51 +501,51 @@
     useFeatureSpecDiff = 1;
     // merge the two peaks if they are close
     if ((fabs(posPeak2SpecDiff - posPeak1SpecDiff) <
-         inst->featureExtractionParams.limitPeakSpacingSpecDiff) &&
+         self->featureExtractionParams.limitPeakSpacingSpecDiff) &&
         (weightPeak2SpecDiff >
-         inst->featureExtractionParams.limitPeakWeightsSpecDiff *
+         self->featureExtractionParams.limitPeakWeightsSpecDiff *
              weightPeak1SpecDiff)) {
       weightPeak1SpecDiff += weightPeak2SpecDiff;
       posPeak1SpecDiff = 0.5f * (posPeak1SpecDiff + posPeak2SpecDiff);
     }
     // get the threshold value
-    inst->priorModelPars[3] =
-        inst->featureExtractionParams.factor1ModelPars * posPeak1SpecDiff;
+    self->priorModelPars[3] =
+        self->featureExtractionParams.factor1ModelPars * posPeak1SpecDiff;
     // reject if weight of peaks is not large enough
     if (weightPeak1SpecDiff <
-        inst->featureExtractionParams.thresWeightSpecDiff) {
+        self->featureExtractionParams.thresWeightSpecDiff) {
       useFeatureSpecDiff = 0;
     }
     // check if value is within min/max range
-    if (inst->priorModelPars[3] < inst->featureExtractionParams.minSpecDiff) {
-      inst->priorModelPars[3] = inst->featureExtractionParams.minSpecDiff;
-    }
-    if (inst->priorModelPars[3] > inst->featureExtractionParams.maxSpecDiff) {
-      inst->priorModelPars[3] = inst->featureExtractionParams.maxSpecDiff;
+    if (self->priorModelPars[3] < self->featureExtractionParams.minSpecDiff) {
+      self->priorModelPars[3] = self->featureExtractionParams.minSpecDiff;
+    }
+    if (self->priorModelPars[3] > self->featureExtractionParams.maxSpecDiff) {
+      self->priorModelPars[3] = self->featureExtractionParams.maxSpecDiff;
     }
     // done with spectral difference feature

     // don't use template feature if fluctuation of lrt feature is very low:
     //  most likely just noise state
-    if (fluctLrt < inst->featureExtractionParams.thresFluctLrt) {
+    if (fluctLrt < self->featureExtractionParams.thresFluctLrt) {
       useFeatureSpecDiff = 0;
     }

     // select the weights between the features
-    // inst->priorModelPars[4] is weight for lrt: always selected
-    // inst->priorModelPars[5] is weight for spectral flatness
-    // inst->priorModelPars[6] is weight for spectral difference
+    // self->priorModelPars[4] is weight for lrt: always selected
+    // self->priorModelPars[5] is weight for spectral flatness
+    // self->priorModelPars[6] is weight for spectral difference
     featureSum = (float)(1 + useFeatureSpecFlat + useFeatureSpecDiff);
-    inst->priorModelPars[4] = 1.f / featureSum;
-    inst->priorModelPars[5] = ((float)useFeatureSpecFlat) / featureSum;
-    inst->priorModelPars[6] = ((float)useFeatureSpecDiff) / featureSum;
+    self->priorModelPars[4] = 1.f / featureSum;
+    self->priorModelPars[5] = ((float)useFeatureSpecFlat) / featureSum;
+    self->priorModelPars[6] = ((float)useFeatureSpecDiff) / featureSum;

     // set hists to zero for next update
-    if (inst->modelUpdatePars[0] >= 1) {
+    if (self->modelUpdatePars[0] >= 1) {
       for (i = 0; i < HIST_PAR_EST; i++) {
-        inst->histLrt[i] = 0;
-        inst->histSpecFlat[i] = 0;
-        inst->histSpecDiff[i] = 0;
+        self->histLrt[i] = 0;
+        self->histSpecFlat[i] = 0;
+        self->histSpecDiff[i] = 0;
       }
     }
   }  // end of flag == 1
@@ -554,7 +554,7 @@
 // Compute spectral flatness on input spectrum
 // magnIn is the magnitude spectrum
 // spectral flatness is returned in inst->featureData[0]
-void WebRtcNs_ComputeSpectralFlatness(NSinst_t* inst, float* magnIn) {
+static void ComputeSpectralFlatness(NSinst_t* const self, const float* magnIn) {
   int i;
   int shiftLP = 1;  // option to remove first bin(s) from spectral measures
   float avgSpectralFlatnessNum, avgSpectralFlatnessDen, spectralTmp;
@@ -562,29 +562,29 @@
   // comute spectral measures
   // for flatness
   avgSpectralFlatnessNum = 0.0;
-  avgSpectralFlatnessDen = inst->sumMagn;
+  avgSpectralFlatnessDen = self->sumMagn;
   for (i = 0; i < shiftLP; i++) {
     avgSpectralFlatnessDen -= magnIn[i];
   }
   // compute log of ratio of the geometric to arithmetic mean: check for log(0)
   // case
-  for (i = shiftLP; i < inst->magnLen; i++) {
+  for (i = shiftLP; i < self->magnLen; i++) {
     if (magnIn[i] > 0.0) {
       avgSpectralFlatnessNum += (float)log(magnIn[i]);
     } else {
-      inst->featureData[0] -= SPECT_FL_TAVG * inst->featureData[0];
+      self->featureData[0] -= SPECT_FL_TAVG * self->featureData[0];
       return;
     }
   }
   // normalize
-  avgSpectralFlatnessDen = avgSpectralFlatnessDen / inst->magnLen;
-  avgSpectralFlatnessNum = avgSpectralFlatnessNum / inst->magnLen;
+  avgSpectralFlatnessDen = avgSpectralFlatnessDen / self->magnLen;
+  avgSpectralFlatnessNum = avgSpectralFlatnessNum / self->magnLen;

   // ratio and inverse log: check for case of log(0)
   spectralTmp = (float)exp(avgSpectralFlatnessNum) / avgSpectralFlatnessDen;

   // time-avg update of spectral flatness feature
-  inst->featureData[0] += SPECT_FL_TAVG * (spectralTmp - inst->featureData[0]);
+  self->featureData[0] += SPECT_FL_TAVG * (spectralTmp - self->featureData[0]);
   // done with flatness feature
 }

@@ -625,44 +625,45 @@
 // magnIn is the input spectrum
 // the reference/template spectrum is inst->magnAvgPause[i]
 // returns (normalized) spectral difference in inst->featureData[4]
-void WebRtcNs_ComputeSpectralDifference(NSinst_t* inst, float* magnIn) {
+static void ComputeSpectralDifference(NSinst_t* const self,
+                                      const float* magnIn) {
   // avgDiffNormMagn = var(magnIn) - cov(magnIn, magnAvgPause)^2 /
   // var(magnAvgPause)
   int i;
   float avgPause, avgMagn, covMagnPause, varPause, varMagn, avgDiffNormMagn;

   avgPause = 0.0;
-  avgMagn = inst->sumMagn;
+  avgMagn = self->sumMagn;
   // compute average quantities
-  for (i = 0; i < inst->magnLen; i++) {
+  for (i = 0; i < self->magnLen; i++) {
     // conservative smooth noise spectrum from pause frames
-    avgPause += inst->magnAvgPause[i];
-  }
-  avgPause = avgPause / ((float)inst->magnLen);
-  avgMagn = avgMagn / ((float)inst->magnLen);
+    avgPause += self->magnAvgPause[i];
+  }
+  avgPause = avgPause / ((float)self->magnLen);
+  avgMagn = avgMagn / ((float)self->magnLen);

   covMagnPause = 0.0;
   varPause = 0.0;
   varMagn = 0.0;
   // compute variance and covariance quantities
-  for (i = 0; i < inst->magnLen; i++) {
-    covMagnPause += (magnIn[i] - avgMagn) * (inst->magnAvgPause[i] - avgPause);
+  for (i = 0; i < self->magnLen; i++) {
+    covMagnPause += (magnIn[i] - avgMagn) * (self->magnAvgPause[i] - avgPause);
     varPause +=
-        (inst->magnAvgPause[i] - avgPause) * (inst->magnAvgPause[i] - avgPause);
+        (self->magnAvgPause[i] - avgPause) * (self->magnAvgPause[i] - avgPause);
     varMagn += (magnIn[i] - avgMagn) * (magnIn[i] - avgMagn);
   }
-  covMagnPause = covMagnPause / ((float)inst->magnLen);
-  varPause = varPause / ((float)inst->magnLen);
-  varMagn = varMagn / ((float)inst->magnLen);
+  covMagnPause = covMagnPause / ((float)self->magnLen);
+  varPause = varPause / ((float)self->magnLen);
+  varMagn = varMagn / ((float)self->magnLen);
   // update of average magnitude spectrum
-  inst->featureData[6] += inst->signalEnergy;
+  self->featureData[6] += self->signalEnergy;

   avgDiffNormMagn =
       varMagn - (covMagnPause * covMagnPause) / (varPause + 0.0001f);
   // normalize and compute time-avg update of difference feature
-  avgDiffNormMagn = (float)(avgDiffNormMagn / (inst->featureData[5] + 0.0001f));
-  inst->featureData[4] +=
-      SPECT_DIFF_TAVG * (avgDiffNormMagn - inst->featureData[4]);
+  avgDiffNormMagn = (float)(avgDiffNormMagn / (self->featureData[5] + 0.0001f));
+  self->featureData[4] +=
+      SPECT_DIFF_TAVG * (avgDiffNormMagn - self->featureData[4]);
 }

 // Compute speech/noise probability
@@ -671,10 +672,10 @@
 // noise is the noise spectrum
 // snrLocPrior is the prior snr for each freq.
 // snr loc_post is the post snr for each freq.
-void WebRtcNs_SpeechNoiseProb(NSinst_t* inst,
-                              float* probSpeechFinal,
-                              float* snrLocPrior,
-                              float* snrLocPost) {
+static void SpeechNoiseProb(NSinst_t* const self,
+                            float* probSpeechFinal,
+                            const float* snrLocPrior,
+                            const float* snrLocPost) {
   int i, sgnMap;
   float invLrt, gainPrior, indPrior;
   float logLrtTimeAvgKsum, besselTmp;
@@ -690,31 +691,31 @@
   widthPrior2 = 2.f * WIDTH_PR_MAP;  // for spectral-difference measure

   // threshold parameters for features
-  threshPrior0 = inst->priorModelPars[0];
-  threshPrior1 = inst->priorModelPars[1];
-  threshPrior2 = inst->priorModelPars[3];
+  threshPrior0 = self->priorModelPars[0];
+  threshPrior1 = self->priorModelPars[1];
+  threshPrior2 = self->priorModelPars[3];

   // sign for flatness feature
-  sgnMap = (int)(inst->priorModelPars[2]);
+  sgnMap = (int)(self->priorModelPars[2]);

   // weight parameters for features
-  weightIndPrior0 = inst->priorModelPars[4];
-  weightIndPrior1 = inst->priorModelPars[5];
-  weightIndPrior2 = inst->priorModelPars[6];
+  weightIndPrior0 = self->priorModelPars[4];
+  weightIndPrior1 = self->priorModelPars[5];
+  weightIndPrior2 = self->priorModelPars[6];

   // compute feature based on average LR factor
   // this is the average over all frequencies of the smooth log lrt
   logLrtTimeAvgKsum = 0.0;
-  for (i = 0; i < inst->magnLen; i++) {
+  for (i = 0; i < self->magnLen; i++) {
     tmpFloat1 = 1.f + 2.f * snrLocPrior[i];
     tmpFloat2 = 2.f * snrLocPrior[i] / (tmpFloat1 + 0.0001f);
     besselTmp = (snrLocPost[i] + 1.f) * tmpFloat2;
-    inst->logLrtTimeAvg[i] +=
-        LRT_TAVG * (besselTmp - (float)log(tmpFloat1) - inst->logLrtTimeAvg[i]);
-    logLrtTimeAvgKsum += inst->logLrtTimeAvg[i];
-  }
-  logLrtTimeAvgKsum = (float)logLrtTimeAvgKsum / (inst->magnLen);
-  inst->featureData[3] = logLrtTimeAvgKsum;
+    self->logLrtTimeAvg[i] +=
+        LRT_TAVG * (besselTmp - (float)log(tmpFloat1) - self->logLrtTimeAvg[i]);
+    logLrtTimeAvgKsum += self->logLrtTimeAvg[i];
+  }
+  logLrtTimeAvgKsum = (float)logLrtTimeAvgKsum / (self->magnLen);
+  self->featureData[3] = logLrtTimeAvgKsum;
   // done with computation of LR factor

   //
@@ -733,7 +734,7 @@
       ((float)tanh(widthPrior * (logLrtTimeAvgKsum - threshPrior0)) + 1.f);

   // spectral flatness feature
-  tmpFloat1 = inst->featureData[0];
+  tmpFloat1 = self->featureData[0];
   widthPrior = widthPrior0;
   // use larger width in tanh map for pause regions
   if (sgnMap == 1 && (tmpFloat1 > threshPrior1)) {
@@ -749,7 +750,7 @@
        1.f);

   // for template spectrum-difference
-  tmpFloat1 = inst->featureData[4];
+  tmpFloat1 = self->featureData[4];
   widthPrior = widthPrior0;
   // use larger width in tanh map for pause regions
   if (tmpFloat1 < threshPrior2) {
@@ -765,22 +766,120 @@
   // done with computing indicator function

   // compute the prior probability
-  inst->priorSpeechProb += PRIOR_UPDATE * (indPrior - inst->priorSpeechProb);
+  self->priorSpeechProb += PRIOR_UPDATE * (indPrior - self->priorSpeechProb);
   // make sure probabilities are within range: keep floor to 0.01
-  if (inst->priorSpeechProb > 1.f) {
-    inst->priorSpeechProb = 1.f;
-  }
-  if (inst->priorSpeechProb < 0.01f) {
-    inst->priorSpeechProb = 0.01f;
+  if (self->priorSpeechProb > 1.f) {
+    self->priorSpeechProb = 1.f;
+  }
+  if (self->priorSpeechProb < 0.01f) {
+    self->priorSpeechProb = 0.01f;
   }

   // final speech probability: combine prior model with LR factor:
-  gainPrior = (1.f - inst->priorSpeechProb) / (inst->priorSpeechProb + 0.0001f);
-  for (i = 0; i < inst->magnLen; i++) {
-    invLrt = (float)exp(-inst->logLrtTimeAvg[i]);
+  gainPrior = (1.f - self->priorSpeechProb) / (self->priorSpeechProb + 0.0001f);
+  for (i = 0; i < self->magnLen; i++) {
+    invLrt = (float)exp(-self->logLrtTimeAvg[i]);
     invLrt = (float)gainPrior * invLrt;
     probSpeechFinal[i] = 1.f / (1.f + invLrt);
   }
+}
+
+// Update the noise features.
+// Inputs:
+//   * |magn| is the signal magnitude spectrum estimate.
+//   * |updateParsFlag| is an update flag for parameters.
+static void FeatureUpdate(NSinst_t* const self,
+                          const float* magn,
+                          int updateParsFlag) {
+  // Compute spectral flatness on input spectrum.
+  ComputeSpectralFlatness(self, magn);
+  // Compute difference of input spectrum with learned/estimated noise spectrum.
+  ComputeSpectralDifference(self, magn);
+  // Compute histograms for parameter decisions (thresholds and weights for
+  // features).
+  // Parameters are extracted once every window time.
+  // (=self->modelUpdatePars[1])
+  if (updateParsFlag >= 1) {
+    // Counter update.
+    self->modelUpdatePars[3]--;
+    // Update histogram.
+    if (self->modelUpdatePars[3] > 0) {
+      FeatureParameterExtraction(self, 0);
+    }
+    // Compute model parameters.
+    if (self->modelUpdatePars[3] == 0) {
+      FeatureParameterExtraction(self, 1);
+      self->modelUpdatePars[3] = self->modelUpdatePars[1];
+      // If wish to update only once, set flag to zero.
+      if (updateParsFlag == 1) {
+        self->modelUpdatePars[0] = 0;
+      } else {
+        // Update every window:
+        // Get normalization for spectral difference for next window estimate.
+        self->featureData[6] =
+            self->featureData[6] / ((float)self->modelUpdatePars[1]);
+        self->featureData[5] =
+            0.5f * (self->featureData[6] + self->featureData[5]);
+        self->featureData[6] = 0.f;
+      }
+    }
+  }
+}
+
+// Update the noise estimate.
+// Inputs:
+//   * |magn| is the signal magnitude spectrum estimate.
+//   * |snrLocPrior| is the prior SNR.
+//   * |snrLocPost| is the post SNR.
+// Output:
+//   * |noise| is the updated noise magnitude spectrum estimate.
+static void UpdateNoiseEstimate(NSinst_t* const self,
+                                const float* magn,
+                                const float* snrLocPrior,
+                                const float* snrLocPost,
+                                float* noise) {
+  int i;
+  float probSpeech, probNonSpeech;
+  // Time-avg parameter for noise update.
+  float gammaNoiseTmp = NOISE_UPDATE;
+  float gammaNoiseOld;
+  float noiseUpdateTmp;
+
+  for (i = 0; i < self->magnLen; i++) {
+    probSpeech = self->speechProb[i];
+    probNonSpeech = 1.f - probSpeech;
+    // Temporary noise update:
+    // Use it for speech frames if update value is less than previous.
+    noiseUpdateTmp = gammaNoiseTmp * self->noisePrev[i] +
+                     (1.f - gammaNoiseTmp) * (probNonSpeech * magn[i] +
+                                              probSpeech * self->noisePrev[i]);
+    //
+    // Time-constant based on speech/noise state.
+    gammaNoiseOld = gammaNoiseTmp;
+    gammaNoiseTmp = NOISE_UPDATE;
+    // Increase gamma (i.e., less noise update) for frame likely to be speech.
+    if (probSpeech > PROB_RANGE) {
+      gammaNoiseTmp = SPEECH_UPDATE;
+    }
+    // Conservative noise update.
+    if (probSpeech < PROB_RANGE) {
+      self->magnAvgPause[i] += GAMMA_PAUSE * (magn[i] - self->magnAvgPause[i]);
+    }
+    // Noise update.
+    if (gammaNoiseTmp == gammaNoiseOld) {
+      noise[i] = noiseUpdateTmp;
+    } else {
+      noise[i] = gammaNoiseTmp * self->noisePrev[i] +
+                 (1.f - gammaNoiseTmp) * (probNonSpeech * magn[i] +
+                                          probSpeech * self->noisePrev[i]);
+      // Allow for noise update downwards:
+      // If noise update decreases the noise, it is safe, so allow it to
+      // happen.
+      if (noiseUpdateTmp < noise[i]) {
+        noise[i] = noiseUpdateTmp;
+      }
+    }
+  }  // End of freq loop.
 }

 // Updates |buffer| with a new |frame|.
@@ -922,9 +1021,7 @@
   float energy;
   float signalEnergy = 0.f;
   float sumMagn = 0.f;
-  float tmpFloat1, tmpFloat2, tmpFloat3, probSpeech, probNonSpeech;
-  float gammaNoiseTmp, gammaNoiseOld;
-  float noiseUpdateTmp;
+  float tmpFloat1, tmpFloat2, tmpFloat3;
   float winData[ANAL_BLOCKL_MAX];
   float magn[HALF_ANAL_BLOCKL], noise[HALF_ANAL_BLOCKL];
   float snrLocPost[HALF_ANAL_BLOCKL], snrLocPrior[HALF_ANAL_BLOCKL];
@@ -986,8 +1083,6 @@
   inst->signalEnergy = signalEnergy;
   inst->sumMagn = sumMagn;

-  // compute spectral flatness on input spectrum
-  WebRtcNs_ComputeSpectralFlatness(inst, magn);
   // quantile noise estimate
   WebRtcNs_NoiseEstimation(inst, magn, noise);
   // compute simplified noise model during startup
@@ -1056,79 +1151,9 @@
   // Post and prior SNR needed for WebRtcNs_SpeechNoiseProb.
   ComputeSnr(inst, magn, noise, snrLocPrior, snrLocPost);

-  // STEP 2: compute speech/noise likelihood
-  // compute difference of input spectrum with learned/estimated noise
-  // spectrum
-  WebRtcNs_ComputeSpectralDifference(inst, magn);
-  // compute histograms for parameter decisions (thresholds and weights for
-  // features)
-  // parameters are extracted once every window time
-  // (=inst->modelUpdatePars[1])
-  if (updateParsFlag >= 1) {
-    // counter update
-    inst->modelUpdatePars[3]--;
-    // update histogram
-    if (inst->modelUpdatePars[3] > 0) {
-      WebRtcNs_FeatureParameterExtraction(inst, 0);
-    }
-    // compute model parameters
-    if (inst->modelUpdatePars[3] == 0) {
-      WebRtcNs_FeatureParameterExtraction(inst, 1);
-      inst->modelUpdatePars[3] = inst->modelUpdatePars[1];
-      // if wish to update only once, set flag to zero
-      if (updateParsFlag == 1) {
-        inst->modelUpdatePars[0] = 0;
-      } else {
-        // update every window:
-        // get normalization for spectral difference for next window estimate
-        inst->featureData[6] =
-            inst->featureData[6] / ((float)inst->modelUpdatePars[1]);
-        inst->featureData[5] =
-            0.5f * (inst->featureData[6] + inst->featureData[5]);
-        inst->featureData[6] = 0.f;
-      }
-    }
-  }
-  // compute speech/noise probability
-  WebRtcNs_SpeechNoiseProb(inst, inst->speechProb, snrLocPrior, snrLocPost);
-  // time-avg parameter for noise update
-  gammaNoiseTmp = NOISE_UPDATE;
-  for (i = 0; i < inst->magnLen; i++) {
-    probSpeech = inst->speechProb[i];
-    probNonSpeech = 1.f - probSpeech;
-    // temporary noise update:
-    // use it for speech frames if update value is less than previous
-    noiseUpdateTmp = gammaNoiseTmp * inst->noisePrev[i] +
-                     (1.f - gammaNoiseTmp) * (probNonSpeech * magn[i] +
-                                              probSpeech * inst->noisePrev[i]);
-    //
-    // time-constant based on speech/noise state
-    gammaNoiseOld = gammaNoiseTmp;
-    gammaNoiseTmp = NOISE_UPDATE;
-    // increase gamma (i.e., less noise update) for frame likely to be speech
-    if (probSpeech > PROB_RANGE) {
-      gammaNoiseTmp = SPEECH_UPDATE;
-    }
-    // conservative noise update
-    if (probSpeech < PROB_RANGE) {
-      inst->magnAvgPause[i] += GAMMA_PAUSE * (magn[i] - inst->magnAvgPause[i]);
-    }
-    // noise update
-    if (gammaNoiseTmp == gammaNoiseOld) {
-      noise[i] = noiseUpdateTmp;
-    } else {
-      noise[i] = gammaNoiseTmp * inst->noisePrev[i] +
-                 (1.f - gammaNoiseTmp) * (probNonSpeech * magn[i] +
-                                          probSpeech * inst->noisePrev[i]);
-      // allow for noise update downwards:
-      // if noise update decreases the noise, it is safe, so allow it to
-      // happen
-      if (noiseUpdateTmp < noise[i]) {
-        noise[i] = noiseUpdateTmp;
-      }
-    }
-  }  // end of freq loop
-  // done with step 2: noise update
+  FeatureUpdate(inst, magn, updateParsFlag);
+  SpeechNoiseProb(inst, inst->speechProb, snrLocPrior, snrLocPost);
+  UpdateNoiseEstimate(inst, magn, snrLocPrior, snrLocPost, noise);

   // keep track of noise spectrum for next frame
   memcpy(inst->noise, noise, sizeof(*noise) * inst->magnLen);


r300/compiler: use perspective division only for TXP in shadow samplers

--- src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
+++ src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
@@ -113,13 +113,13 @@
 			return 1;
 		} else {
 			rc_compare_func comparefunc = compiler->state.unit[inst->U.I.TexSrcUnit].texture_compare_func;
-			struct rc_instruction * inst_rcp = rc_insert_new_instruction(c, inst);
-			struct rc_instruction * inst_mad = rc_insert_new_instruction(c, inst_rcp);
-			struct rc_instruction * inst_cmp = rc_insert_new_instruction(c, inst_mad);
-			unsigned tmp_recip_w = rc_find_free_temporary(c);
+			struct rc_instruction * inst_rcp = NULL;
+			struct rc_instruction * inst_mad;
+			struct rc_instruction * inst_cmp;
 			unsigned tmp_texsample = rc_find_free_temporary(c);
 			unsigned tmp_sum = rc_find_free_temporary(c);
-			int pass, fail;
+			unsigned tmp_recip_w;
+			int pass, fail, tex;

 			/* Save the output register. */
 			struct rc_dst_register output_reg = inst->U.I.DstReg;
@@ -129,28 +129,40 @@
 			inst->U.I.DstReg.Index = tmp_texsample;
 			inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;

-			/* Compute 1/W. */
-			inst_rcp->U.I.Opcode = RC_OPCODE_RCP;
-			inst_rcp->U.I.DstReg.File = RC_FILE_TEMPORARY;
-			inst_rcp->U.I.DstReg.Index = tmp_recip_w;
-			inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W;
-			inst_rcp->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
-			inst_rcp->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_WWWW;
-
-			/* Perspective-divide r (=depth) by W and add the texture sample (see below). */
-			inst_mad->U.I.Opcode = RC_OPCODE_MAD;
+			if (inst->U.I.Opcode == RC_OPCODE_TXP) {
+				tmp_recip_w = rc_find_free_temporary(c);
+
+				/* Compute 1/W. */
+				inst_rcp = rc_insert_new_instruction(c, inst);
+				inst_rcp->U.I.Opcode = RC_OPCODE_RCP;
+				inst_rcp->U.I.DstReg.File = RC_FILE_TEMPORARY;
+				inst_rcp->U.I.DstReg.Index = tmp_recip_w;
+				inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W;
+				inst_rcp->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+				inst_rcp->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_WWWW;
+			}
+
+			/* Perspective-divide r by W (if it's TXP) and add the texture sample (see below). */
+			inst_mad = rc_insert_new_instruction(c, inst_rcp ? inst_rcp : inst);
 			inst_mad->U.I.DstReg.File = RC_FILE_TEMPORARY;
 			inst_mad->U.I.DstReg.Index = tmp_sum;
 			inst_mad->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
 			inst_mad->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_ZZZZ;
-			inst_mad->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
-			inst_mad->U.I.SrcReg[1].Index = tmp_recip_w;
-			inst_mad->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW;
-			inst_mad->U.I.SrcReg[2].File = RC_FILE_TEMPORARY;
-			inst_mad->U.I.SrcReg[2].Index = tmp_texsample;
-			inst_mad->U.I.SrcReg[2].Swizzle = compiler->state.unit[inst->U.I.TexSrcUnit].depth_texture_swizzle;
-
-			/* Recall that SrcReg[0] is tex, SrcReg[2] is r and:
+			if (inst->U.I.Opcode == RC_OPCODE_TXP) {
+				inst_mad->U.I.Opcode = RC_OPCODE_MAD;
+				inst_mad->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+				inst_mad->U.I.SrcReg[1].Index = tmp_recip_w;
+				inst_mad->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW;
+				tex = 2;
+			} else {
+				inst_mad->U.I.Opcode = RC_OPCODE_ADD;
+				tex = 1;
+			}
+			inst_mad->U.I.SrcReg[tex].File = RC_FILE_TEMPORARY;
+			inst_mad->U.I.SrcReg[tex].Index = tmp_texsample;
+			inst_mad->U.I.SrcReg[tex].Swizzle = compiler->state.unit[inst->U.I.TexSrcUnit].depth_texture_swizzle;
+
+			/* Recall that SrcReg[0] is r, SrcReg[tex] is tex and:
 			 *   LESS:    r  < tex  <=>      -tex+r < 0
 			 *   GEQUAL:  r >= tex  <=> not (-tex+r < 0)
 			 *   GREATER: r  > tex  <=>       tex-r < 0
@@ -158,7 +170,7 @@
 			 *
 			 * This negates either r or tex: */
 			if (comparefunc == RC_COMPARE_FUNC_LESS || comparefunc == RC_COMPARE_FUNC_GEQUAL)
-				inst_mad->U.I.SrcReg[2].Negate = inst_mad->U.I.SrcReg[2].Negate ^ RC_MASK_XYZW;
+				inst_mad->U.I.SrcReg[tex].Negate = inst_mad->U.I.SrcReg[tex].Negate ^ RC_MASK_XYZW;
 			else
 				inst_mad->U.I.SrcReg[0].Negate = inst_mad->U.I.SrcReg[0].Negate ^ RC_MASK_XYZW;

@@ -171,6 +183,7 @@
 				fail = 1;
 			}

+			inst_cmp = rc_insert_new_instruction(c, inst_mad);
 			inst_cmp->U.I.Opcode = RC_OPCODE_CMP;
 			inst_cmp->U.I.DstReg = output_reg;
 			inst_cmp->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;


Slight error Fixed adding code in wrong error and a past fix that may not have been adequate.

--- src/test/histogram_perf.c
+++ src/test/histogram_perf.c
@@ -78,12 +78,8 @@
       gettimeofday(&finish, NULL);
       double elapsed = finish.tv_sec - start.tv_sec;
       elapsed += (finish.tv_usec/1000000.0) - (start.tv_usec/1000000.0);
-      if(cnt != 0)
       printf("ops: %ld, time: %gs, time-per-op: %0.2fns\n",
              cnt, elapsed, (elapsed / (double)cnt) * 1000000000.0);
-      else
-      printf("ops: %ld, time: %gs, time-per-op: %0.2fns\n",
-             cnt, elapsed, (elapsed / 1) * 1000000000.0);
       hist_free(hist);
       free(vals);
 }
@@ -104,9 +100,12 @@
       gettimeofday(&finish, NULL);
       double elapsed = finish.tv_sec - start.tv_sec;
       elapsed += (finish.tv_usec/1000000.0) - (start.tv_usec/1000000.0);
-      assert(cnt != 0);
+      if(cnt != 0)
       printf("ops: %ld, time: %gs, time-per-op: %0.2fns\n",
              cnt, elapsed, (elapsed / (double)cnt) * 1000000000.0);
+      else
+      printf("ops: %ld, time: %gs, time-per-op: %0.2fns\n",
+             cnt, elapsed, (elapsed / 1) * 1000000000.0);
       hist_free(hist);
       free(vals);
 }


fix double free

fix double free

eina_hash_del calls free callback, so we don't need to free the data
ourselves.

git-svn-id: 73370f4beb622e00b1e5fc4f999aefcb9ce2f227@49247 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/efreet_desktop.c
+++ src/lib/efreet_desktop.c
@@ -1609,8 +1609,6 @@

         case ECORE_FILE_EVENT_DELETED_SELF:
         case ECORE_FILE_EVENT_DELETED_DIRECTORY:
-            fm = eina_hash_find(change_monitors, path);
-            if (fm) ecore_file_monitor_del(fm);
             eina_hash_del_by_key(change_monitors, path);
             efreet_desktop_update_cache();
             break;


Reduce type size to keep light index.

Reduce type size to keep light index.

--- src/libidaten/svgf/svgf.h
+++ src/libidaten/svgf/svgf.h
@@ -50,7 +50,8 @@
 			aten::vec3 raydir[ShdowRayNum];
 			aten::vec3 lightcontrib[ShdowRayNum];
 			real distToLight[ShdowRayNum];
-			int targetLightId[ShdowRayNum];
+
+			uint8_t targetLightId[ShdowRayNum];

 			struct {
 				uint32_t isActive : 1;


[MIX] Fix shift commands (incorrect work with std::vallarray, incorrect Byte indexes)

--- src/mix_lib/source/internal/valarray_register_helpers.h
+++ src/mix_lib/source/internal/valarray_register_helpers.h
@@ -23,7 +23,7 @@

 inline std::valarray<Byte> ToBytes(const Register& r1, const Register& r2)
 {
-	std::valarray<Byte> result{2 * Word::k_bytes_count};
+	std::valarray<Byte> result(std::size_t{2 * Word::k_bytes_count});

 	std::copy(begin(r1.bytes()), end(r1.bytes()), begin(result));
 	std::copy(begin(r2.bytes()), end(r2.bytes()), begin(result) + Word::k_bytes_count);
@@ -52,7 +52,7 @@
 	for (std::size_t i = 1; i <= 5; ++i)
 	{
 		r1.set_byte(i, bytes[i - 1]);
-		r2.set_byte(i + 5, bytes[i + 5 - 1]);
+		r2.set_byte(i, bytes[i + 5 - 1]);
 	}
 	return std::make_pair(std::move(r1), std::move(r2));
 }


TODO++

TODO++

git-svn-id: 84b01a431a35ab4b2cbd4207035e868bef694d71@33833 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/efreet_desktop.c
+++ src/lib/efreet_desktop.c
@@ -1766,6 +1766,7 @@
     {
         Ecore_List *execs;
         execs = efreet_desktop_command_build(f->command);
+        /* TODO: Need to handle the return value from efreet_desktop_command_execs_process */
         efreet_desktop_command_execs_process(f->command, execs);
         ecore_list_destroy(execs);
         efreet_desktop_command_free(f->command);


fix build on thresher - missing constants

TBR=r
OCL=24439
CL=24439

--- src/libmach_amd64/linux.c
+++ src/libmach_amd64/linux.c
@@ -40,6 +40,31 @@
 #include <mach_amd64.h>
 #include <ureg_amd64.h>
 #undef waitpid
+
+// The old glibc used with crosstool compilers on thresher
+// doesn't know these numbers, but the Linux kernel
+// had them as far back as 2.6.0.
+#ifndef WSTOPPED
+#define WSTOPPED 2
+#define WCONTINUED 8
+#define WIFCONTINUED(x) ((x) == 0xffff)
+#endif
+#ifndef PTRACE_SETOPTIONS
+#define PTRACE_SETOPTIONS 0x4200
+#define PTRACE_GETEVENTMSG 0x4201
+#define PTRACE_O_TRACEFORK 0x2
+#define PTRACE_O_TRACEVFORK 0x4
+#define PTRACE_O_TRACECLONE 0x8
+#define PTRACE_O_TRACEEXEC 0x10
+#define PTRACE_O_TRACEVFORKDONE 0x20
+#define PTRACE_O_TRACEEXIT 0x40
+#define PTRACE_EVENT_FORK 0x1
+#define PTRACE_EVENT_VFORK 0x2
+#define PTRACE_EVENT_CLONE 0x3
+#define PTRACE_EVENT_EXEC 0x4
+#define PTRACE_EVENT_VFORK_DONE 0x5
+#define PTRACE_EVENT_EXIT 0x6
+#endif

 typedef struct Ureg Ureg;


Fix single quouting, patch from ���������� ����������

git-svn-id: 84b01a431a35ab4b2cbd4207035e868bef694d71@35013 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/efreet_desktop.c
+++ src/lib/efreet_desktop.c
@@ -1467,7 +1467,7 @@
         while (*p)
         {
             if (*p == '\'')
-                dest = efreet_string_append_char(dest, size, len, '\\');
+                dest = efreet_string_append(dest, size, len, "\'\\\'");

             dest = efreet_string_append_char(dest, size, len, *p);
             p++;


Suppress gcc array bounds warning in test_zeropage


* eina_rectangle: Fix typo.

	* eina_rectangle: Fix typo.

git-svn-id: a6113611d365f0fc061992be0d1d0b451b434026@41158 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/eina_rectangle.c
+++ src/lib/eina_rectangle.c
@@ -239,7 +239,7 @@
    if (!new) return NULL;

    new->head = NULL;
-   new->empty = eina_list_append(NULL, eina_rectangle_add(0, 0, w, h));
+   new->empty = eina_list_append(NULL, eina_rectangle_new(0, 0, w, h));
    new->references = 0;
    new->w = w;
    new->h = h;


[svn] remove useless commented lines

[svn] remove useless commented lines

--- src/modules/browser/localfiles/enna_module_localfiles.c
+++ src/modules/browser/localfiles/enna_module_localfiles.c
@@ -4,8 +4,6 @@

 static void           _class_init();
 static void           _class_shutdown();
-//static Evas_List     *_class_browse_up(const char *path, int type);
-//static Evas_List     *_class_browse_down(int type);
 static Enna_Vfs_File *_class_vfs_get(int type);

 static Evas_List     *_class_browse_up_music(const char *path);


add async echo server

add async echo server

error: pathspec 'apr/async_tcp_echo_server.c' did not match any file(s) known to git

--- apr/async_tcp_echo_server.c
+++ apr/async_tcp_echo_server.c
@@ -0,0 +1,255 @@
+/**
+ * Alexis Giraudet
+ * 2015
+ *
+ * Async tcp echo server using APR
+ * http://apr.apache.org/
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <apr-1/apr_general.h>
+#include <apr-1/apr_network_io.h>
+#include <apr-1/apr_poll.h>
+#include <apr-1/apr_strings.h>
+
+#define ERR_BUF_LEN 128
+#define MSG_BUF_LEN 128
+#define MAX_DESCRIPTORS 128
+#define MAX_CONNECTIONS 128
+
+static char err_buf[ERR_BUF_LEN];
+
+typedef struct baton_s
+{
+    apr_pool_t * pool;
+    apr_socket_t * sock;
+    apr_pollcb_t * poll_cb;
+} baton_t;
+
+typedef struct client_data_s
+{
+    apr_pool_t * pool;
+    char * buf;
+    apr_size_t buf_len;
+    apr_status_t status;
+} client_data_t;
+
+apr_status_t pollcb_cb(void * data, apr_pollfd_t * poll_fd)
+{
+    baton_t * baton = data;
+    apr_status_t status;
+    apr_socket_t * new_sock;
+    apr_pool_t * new_pool;
+    apr_pollfd_t new_pollfd;
+    client_data_t * sock_data;
+
+    printf("%p ", poll_fd->desc.s);
+
+    if(APR_POLLIN & poll_fd->rtnevents)
+        printf("POLLIN");
+
+    if(APR_POLLPRI & poll_fd->rtnevents)
+        printf("POLLPRI");
+
+    if(APR_POLLOUT & poll_fd->rtnevents)
+        printf("POLLOUT");
+
+    if(APR_POLLERR & poll_fd->rtnevents)
+        printf("POLLERR");
+
+    if(APR_POLLHUP & poll_fd->rtnevents)
+        printf("POLLHUB");
+
+    if(APR_POLLNVAL & poll_fd->rtnevents)
+        printf("POLLNVAL");
+
+    if(baton->sock == poll_fd->desc.s)
+    {
+        printf(" (listener)\n");
+
+        if(APR_POLLIN & poll_fd->rtnevents)
+        {
+            printf("accept\n");
+
+            status = apr_pool_create(&new_pool, baton->pool);
+            if(status)
+                return status;
+
+            status = apr_socket_accept(&new_sock, baton->sock, new_pool);
+            if(status)
+                return status;
+
+            status = apr_socket_opt_set(new_sock, APR_SO_NONBLOCK, 1);
+            if(status)
+                return status;
+
+            status = apr_socket_timeout_set(new_sock, 0);
+            if(status)
+                return status;
+
+            sock_data = apr_palloc(new_pool, sizeof(client_data_t));
+            sock_data->pool = new_pool;
+            sock_data->buf = apr_palloc(new_pool, MSG_BUF_LEN);
+            sock_data->buf_len = 0;
+            sock_data->status = 0;
+
+            new_pollfd.p = new_pool;
+            new_pollfd.desc_type = APR_POLL_SOCKET;
+            new_pollfd.reqevents = APR_POLLIN /*| APR_POLLPRI | APR_POLLOUT | APR_POLLERR | APR_POLLHUP | APR_POLLNVAL*/;
+            new_pollfd.rtnevents = 0;
+            new_pollfd.desc.s = new_sock;
+            new_pollfd.client_data = sock_data;
+
+            status = apr_pollcb_add(baton->poll_cb, &new_pollfd);
+            if(status)
+                return status;
+        }
+    }
+    else
+    {
+        printf(" (client)\n");
+
+        new_pollfd.p = poll_fd->p;
+        new_pollfd.desc_type = poll_fd->desc_type;
+        new_pollfd.rtnevents = poll_fd->rtnevents;
+        new_pollfd.desc.s = poll_fd->desc.s;
+        new_pollfd.client_data = poll_fd->client_data;
+
+        sock_data = poll_fd->client_data;
+
+        status = apr_pollcb_remove(baton->poll_cb, poll_fd);
+        if(status)
+            return status;
+
+        if(APR_POLLIN & new_pollfd.rtnevents)
+        {
+            printf("read\n");
+
+            new_pollfd.reqevents = APR_POLLOUT;
+            sock_data->buf_len = MSG_BUF_LEN;
+            sock_data->status = apr_socket_recv(new_pollfd.desc.s, sock_data->buf, &(sock_data->buf_len));
+        }
+
+        if(APR_POLLOUT & new_pollfd.rtnevents)
+        {
+            printf("write\n");
+
+            new_pollfd.reqevents = APR_POLLIN;
+            status = apr_socket_send(new_pollfd.desc.s, sock_data->buf, &(sock_data->buf_len));
+            if(status)
+                return status;
+        }
+
+        if(sock_data->status)
+        {
+            status  = apr_socket_close(new_pollfd.desc.s);
+            apr_pool_destroy(sock_data->pool);
+            if(status)
+                return status;
+        }
+        else
+        {
+            status = apr_pollcb_add(baton->poll_cb, &new_pollfd);
+            if(status)
+                return status;
+        }
+    }
+
+    return APR_SUCCESS;
+}
+
+apr_status_t server(apr_port_t port, apr_pool_t * pool)
+{
+    apr_status_t status;
+    apr_socket_t * sock;
+    apr_sockaddr_t * sockaddr;
+    apr_pool_t * local_pool;
+    apr_pollcb_t * poll_cb;
+    apr_pollfd_t poll_fd;
+    baton_t baton;
+
+    status = apr_pool_create(&local_pool, pool);
+    if(status)
+        return status;
+
+    status = apr_sockaddr_info_get(&sockaddr, NULL, APR_UNSPEC, port, 0, local_pool);
+    if(status)
+        return status;
+
+    status = apr_socket_create(&sock, sockaddr->family, SOCK_STREAM, APR_PROTO_TCP, local_pool);
+    if(status)
+        return status;
+
+    status = apr_socket_opt_set(sock, APR_SO_NONBLOCK, 1);
+    if(status)
+        return status;
+
+    status = apr_socket_timeout_set(sock, 0);
+    if(status)
+        return status;
+
+    status = apr_socket_bind(sock, sockaddr);
+    if(status)
+        return status;
+
+    status = apr_socket_listen(sock, MAX_CONNECTIONS);
+    if(status)
+        return status;
+
+    status = apr_pollcb_create(&poll_cb, MAX_DESCRIPTORS, local_pool, 0);
+    if(status)
+        return status;
+
+    poll_fd.p = local_pool;
+    poll_fd.desc_type = APR_POLL_SOCKET;
+    poll_fd.reqevents = APR_POLLIN /*| APR_POLLPRI | APR_POLLOUT | APR_POLLERR | APR_POLLHUP | APR_POLLNVAL*/;
+    poll_fd.rtnevents = 0;
+    poll_fd.desc.s = sock;
+    poll_fd.client_data = NULL;
+
+    baton.sock = sock;
+    baton.pool = local_pool;
+    baton.poll_cb = poll_cb;
+
+    status = apr_pollcb_add(poll_cb, &poll_fd);
+    if(status)
+        return status;
+
+    for(;;)
+    {
+        status = apr_pollcb_poll(poll_cb, -1, pollcb_cb, &baton);
+        if(status)
+            break;
+    }
+
+    return status;
+}
+
+int main(int argc, char const *argv[])
+{
+    apr_status_t status;
+    char * err_msg;
+
+    status = atexit(apr_terminate);
+    if(status)
+        return status;
+
+    status = apr_initialize();
+    if(status)
+        return status;
+
+    if(argc != 2)
+    {
+        fprintf(stderr, "Usage: %s PORT\n", argv[0]);
+        return APR_BADARG;
+    }
+
+    status = server(apr_atoi64(argv[1]), NULL);
+
+    err_msg = apr_strerror(status, err_buf, ERR_BUF_LEN);
+    printf("Error: %s\n", err_msg);
+
+    return status;
+}


Revert that commit...my bad, misread some code.

SVN revision: 49307

--- src/modules/conf_keybindings/e_int_config_keybindings.c
+++ src/modules/conf_keybindings/e_int_config_keybindings.c
@@ -181,6 +181,9 @@
      {
 	e_bindings_key_del(bi->context, bi->key, bi->modifiers, bi->any_mod,
 			   bi->action, bi->params);
+	if (bi->key) eina_stringshare_del(bi->key);
+	if (bi->action) eina_stringshare_del(bi->action);
+	if (bi->params) eina_stringshare_del(bi->params);
 	E_FREE(bi);
      }


Make sure variables are referenced in CHECK macros, even for official builds.

Previously the GCC based builds couldn't build with OFFICIAL_BUILD, since code like:

bool success = Something();
DCHECK(success);

Would result in a compile warning (treated as error) about success being unused.

Review URL: http://codereview.chromium.org/18747

git-svn-id: http://src.chromium.org/svn/trunk/src@8630 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: 7fb5f9a3fe81dc64087722cc2dbeeafb934e586e

--- base/logging.h
+++ base/logging.h
@@ -277,41 +277,43 @@
 // non-debug mode. The DCHECK and friends macros use this so that
 // the expanded expression DCHECK(foo) << "asdf" is still syntactically
 // valid, even though the expression will get optimized away.
+// In order to avoid variable unused warnings for code that only uses a
+// variable in a CHECK, we make sure to use the macro arguments.
 #define NDEBUG_EAT_STREAM_PARAMETERS \
   logging::LogMessage(__FILE__, __LINE__).stream()

 #define DCHECK(condition) \
-  while (false) NDEBUG_EAT_STREAM_PARAMETERS
+  while (false && (condition)) NDEBUG_EAT_STREAM_PARAMETERS

 #define DCHECK_EQ(val1, val2) \
-  while (false) NDEBUG_EAT_STREAM_PARAMETERS
+  while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS

 #define DCHECK_NE(val1, val2) \
-  while (false) NDEBUG_EAT_STREAM_PARAMETERS
+  while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS

 #define DCHECK_LE(val1, val2) \
-  while (false) NDEBUG_EAT_STREAM_PARAMETERS
+  while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS

 #define DCHECK_LT(val1, val2) \
-  while (false) NDEBUG_EAT_STREAM_PARAMETERS
+  while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS

 #define DCHECK_GE(val1, val2) \
-  while (false) NDEBUG_EAT_STREAM_PARAMETERS
+  while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS

 #define DCHECK_GT(val1, val2) \
-  while (false) NDEBUG_EAT_STREAM_PARAMETERS
+  while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS

 #define DCHECK_STREQ(str1, str2) \
-  while (false) NDEBUG_EAT_STREAM_PARAMETERS
+  while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS

 #define DCHECK_STRCASEEQ(str1, str2) \
-  while (false) NDEBUG_EAT_STREAM_PARAMETERS
+  while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS

 #define DCHECK_STRNE(str1, str2) \
-  while (false) NDEBUG_EAT_STREAM_PARAMETERS
+  while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS

 #define DCHECK_STRCASENE(str1, str2) \
-  while (false) NDEBUG_EAT_STREAM_PARAMETERS
+  while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS

 #else
 #ifndef NDEBUG


e was broken, fixies.

e was broken, fixies.

--- src/modules/conf_wallpaper/e_int_config_wallpaper_web.c
+++ src/modules/conf_wallpaper/e_int_config_wallpaper_web.c
@@ -42,7 +42,7 @@
    const char *source;
 };

-#define TEMPLATE "/tmp/wallpXXXXXX";
+#define TEMPLATE "/tmp/wallpXXXXXX"

 static void _file_double_click_cb(void *data, Evas_Object *obj, void *ev_info);
 static void _file_click_cb(void *data, Evas_Object *obj, void *ev_info);
@@ -316,6 +316,7 @@
    char instr[1024];
    char *edj;
    char *img;
+   char *title;

    int state = -1;

@@ -340,9 +341,9 @@
 	  {
 	     char *p;

-	     edj = strchr(instr, ">");
+	     edj = strchr(instr, '>');
 	     edj++;
-	     p = strchr(edj, "<");
+	     p = strchr(edj, '<');
 	     *p = 0;
 	     p = strrchr(ecore_file_file_get(edj), '.');
 	     if (!strcmp(p, ".edj"))


[demo] Added a new path for test cases

[demo] Added a new path for test cases

Added a complex opened curve (with more than one Bézier primitive)
to expose the weakness of the offset algorithm.

--- demo/cpml-demo.c
+++ demo/cpml-demo.c
@@ -16,6 +16,7 @@

 static void     append_circle           (cairo_t        *cr);
 static void     append_piston           (cairo_t        *cr);
+static void     append_complex_curve    (cairo_t        *cr);

 static CpmlPair bezier_samples[][4] = {
     { { 0, 0 }, { 0, 40 }, { 120, 40 }, { 120, 0 } },   /* Simmetric low */
@@ -200,19 +201,31 @@

     path = duplicate_and_stroke(cr);
     cpml_segment_from_cairo(&segment, path);
-    cpml_segment_offset(&segment, 20.);
+    cpml_segment_offset(&segment, 15.);
     stroke_and_destroy(cr, path);

-    /* Offset a more complex path */
+    /* Offset a piston path, a common path in technical drawing */
     cairo_save(cr);
-    cairo_translate(cr, 240.5, 120.5);
+    cairo_translate(cr, 220.5, 120.5);
     cairo_scale(cr, 10., 10.);
     append_piston(cr);
     cairo_restore(cr);

     path = duplicate_and_stroke(cr);
     cpml_segment_from_cairo(&segment, path);
-    cpml_segment_offset(&segment, 10.);
+    cpml_segment_offset(&segment, 15.);
+    stroke_and_destroy(cr, path);
+
+    /* Offset a complex curve, quite uncommon in technical drawing*/
+    cairo_save(cr);
+    cairo_translate(cr, 40., 340.);
+    cairo_scale(cr, 10., 10.);
+    append_complex_curve(cr);
+    cairo_restore(cr);
+
+    path = duplicate_and_stroke(cr);
+    cpml_segment_from_cairo(&segment, path);
+    cpml_segment_offset(&segment, 15.);
     stroke_and_destroy(cr, path);

     cairo_destroy(cr);
@@ -233,7 +246,7 @@
     cairo_matrix_t matrix;
     CpmlSegment segment;

-    cairo_move_to(cr,  0.,    4.65);
+    cairo_move_to(cr,  5.,    4.65);
     cairo_line_to(cr, 26.,    4.65);
     cairo_line_to(cr, 27.25,  3.5);
     cairo_line_to(cr, 32,     3.5);
@@ -246,7 +259,7 @@
     cairo_line_to(cr, 46.,    2.25);
     cairo_line_to(cr, 50.,    2.25);
     cairo_arc_negative(cr,
-                      50.2,   3.4,   0.2, G_PI, G_PI_2);
+                      50.2,   3.4, 0.2,  G_PI,      G_PI_2);
     cairo_line_to(cr, 51.,    3.6);
     cairo_line_to(cr, 52.,    3.);
     cairo_line_to(cr, 52.2,   1.25);
@@ -267,3 +280,13 @@
     /* ...and close the shape */
     cairo_close_path(cr);
 }
+
+static void
+append_complex_curve(cairo_t *cr)
+{
+    cairo_move_to(cr,    0.,  0.);
+    cairo_curve_to(cr,  12., 12.,  13., 10.,  13.,  2.);
+    cairo_curve_to(cr,  13., -2.,   5.,  4.,  15.,  4.);
+    cairo_curve_to(cr,  25.,  4.,  25., -6.,  15., -6.);
+    cairo_curve_to(cr,   5., -6.,  10., -2.,   8., -9.);
+}


Fix memory leak caused by using free(), not free-ing protobuf structure.

--- src/lib/kinetic_logger.c
+++ src/lib/kinetic_logger.c
@@ -372,7 +372,7 @@
                             KineticProto_Command * cmd = KineticProto_command__unpack(NULL, value->len, value->data);
                             log_protobuf_message(log_level, &cmd->base, indent);
                             log_proto_level_end();
-                            free(cmd);
+                            KineticProto_command__free_unpacked(cmd, NULL);
                         }
                     }
                     else {


Sync with the latest liblbfgs.

Sync with the latest liblbfgs.

git-svn-id: a77ea9f80e9ea6f26972a8f604fbddfe93a5c55c@160 e255bd1e-7e62-11dc-b0bd-8f205bbbb416

--- lib/crf/src/crf1m_learn_lbfgs.c
+++ lib/crf/src/crf1m_learn_lbfgs.c
@@ -292,7 +292,7 @@
     if (strcmp(lbfgsopt->linesearch, "Backtracking") == 0) {
         lbfgsparam.linesearch = LBFGS_LINESEARCH_BACKTRACKING;
     } else if (strcmp(lbfgsopt->linesearch, "StrongBacktracking") == 0) {
-        lbfgsparam.linesearch = LBFGS_LINESEARCH_BACKTRACKING_STRONG;
+        lbfgsparam.linesearch = LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE;
     } else {
         lbfgsparam.linesearch = LBFGS_LINESEARCH_MORETHUENTE;
     }


JNI bindings: call input signal listener.

Works, but needs improvement: JVM environment is passed through a
global (not thread-safe), and a global reference to the listener is
created which is never deleted.

--- jni/mapperjni.c
+++ jni/mapperjni.c
@@ -2,6 +2,8 @@
 #include <mapper/mapper.h>

 #include "Mapper_Device.h"
+
+JNIEnv *genv=0;

 JNIEXPORT void JNICALL Java_Mdev_t
   (JNIEnv *env, jobject obj, jint i, jstring s)
@@ -50,12 +52,33 @@
 JNIEXPORT int JNICALL Java_Mapper_Device_mdev_1poll
   (JNIEnv *env, jobject obj, jlong d, jint timeout)
 {
+    genv = env;
     mapper_device dev = (mapper_device)d;
     return mdev_poll(dev, timeout);
 }

+static void java_msig_input_cb(mapper_signal sig, void *v)
+{
+    printf("in callback, genv=%p\n", genv);
+    mapper_db_signal props = msig_properties(sig);
+    jobject listener = (jobject)props->user_data;
+    if (listener) {
+        jclass cls = (*genv)->GetObjectClass(genv, listener);
+        printf("listener class: %p\n", cls);
+        if (cls) {
+            jmethodID val = (*genv)->GetMethodID(genv, cls, "onInput", "()V");
+            if (val) {
+                printf("got onInput: %p\n", val);
+                (*genv)->CallVoidMethod(genv, listener, val);
+            }
+            else
+                printf("couldn't get onInput\n");
+        }
+    }
+}
+
 JNIEXPORT jlong JNICALL Java_Mapper_Device_mdev_1add_1input
-  (JNIEnv *env, jobject obj, jlong d, jstring name, jint length, jchar type, jstring unit, jobject minimum, jobject maximum, jobject handler)
+  (JNIEnv *env, jobject obj, jlong d, jstring name, jint length, jchar type, jstring unit, jobject minimum, jobject maximum, jobject listener)
 {
     if (!d || !name || (length<=0) || (type!='f' && type!='i'))
         return 0;
@@ -100,7 +123,8 @@
     mapper_signal s = mdev_add_input(dev, cname, length, type, cunit,
                                      minimum ? &mn : 0,
                                      maximum ? &mx : 0,
-                                     0, 0);
+                                     java_msig_input_cb,
+                                     (*env)->NewGlobalRef(env, listener));

     (*env)->ReleaseStringUTFChars(env, name, cname);
     if (unit) (*env)->ReleaseStringUTFChars(env, unit, cunit);


libpcp: check pmInResult->namelist for NULL before accessing first element

--- src/libpcp/src/instance.c
+++ src/libpcp/src/instance.c
@@ -177,7 +177,7 @@
 		if (sts == PDU_INSTANCE) {
 		    pmInResult *result;
 		    if ((sts = __pmDecodeInstance(pb, &result)) >= 0) {
-			if ((*name = strdup(result->namelist[0])) == NULL)
+			if (result->namelist == NULL || (*name = strdup(result->namelist[0])) == NULL)
 			    sts = -oserror();
 			__pmFreeInResult(result);
 		    }


changing names_valueparam to build a paramref

--- src/libponyc/pass/names.c
+++ src/libponyc/pass/names.c
@@ -193,11 +193,8 @@
     return false;
   }

-  // FIXME: make this a typevaluref or a ref
-  // the latter will get swithced out
-  // should be teh second and handled correctly
   BUILD(ref, ast,
-    NODE(TK_REFERENCE,
+    NODE(TK_VALUEFORMALPARAMREF,
       TREE(id)));

   REPLACE(astp,


Fix formatting: __LINE__ is a number, not a string

--- src/libreset/util/debug.h
+++ src/libreset/util/debug.h
@@ -54,7 +54,7 @@
  */
 #define dbg(fmt,...) do {                       \
         fprintf(stderr,                         \
-                "[libreset][%s][%s][%s]: "fmt,  \
+                "[libreset][%s][%s][%i]: "fmt,  \
                 __FILE__,                       \
                 __func__,                       \
                 __LINE__,                       \


Another fix for parse host/port.

Another fix for parse host/port.

--- src/libserver/cfg_utils.c
+++ src/libserver/cfg_utils.c
@@ -113,20 +113,22 @@
 			}
 		}
 		if (priority != NULL) {
+			const gchar *tok;
+
 			if (port != NULL) {
-				cur_tok = tokens[2];
+				tok = tokens[2];
 			}
 			else {
-				cur_tok = tokens[1];
-			}
-			if (cur_tok != NULL) {
+				tok = tokens[1];
+			}
+			if (tok != NULL) {
 				/* Priority part */
 				errno = 0;
-				priority_parsed = strtoul (cur_tok, &err_str, 10);
+				priority_parsed = strtoul (tok, &err_str, 10);
 				if (*err_str != '\0' || errno != 0) {
 					msg_warn (
 						"cannot parse priority: %s, at symbol %c, error: %s",
-						tokens[1],
+						tok,
 						*err_str,
 						strerror (errno));
 				}
@@ -144,7 +146,7 @@
 		cur_port = NULL;
 	}

-	if ((r = getaddrinfo (tokens[0], cur_port, &hints, &res)) == 0) {
+	if ((r = getaddrinfo (cur_tok, cur_port, &hints, &res)) == 0) {
 		memcpy (&addr_holder, res->ai_addr,
 			MIN (sizeof (addr_holder), res->ai_addrlen));
 		if (res->ai_family == AF_INET) {


Zero-pad alarm values.

Zero-pad alarm values.

--- decode_alarm.c
+++ decode_alarm.c
@@ -63,7 +63,7 @@
 	else {
 		wattron(alarm_win, COLOR_PAIR(3) | A_BOLD);
 		mvwprintw(alarm_win, 1, 22,
-		    "0x%1x 0x%1x 0x%1x 0x%1x 0x%3x 0x%1x 0x%3x\n 0x%1x",
+		    "0x%1x 0x%1x 0x%1x 0x%1x 0x%03x 0x%1x 0x%03x\n 0x%1x",
 		    ds1, ps1, ds2, ps2, dl1, pl1, dl2, pl2);
 		wattroff(alarm_win, COLOR_PAIR(3) | A_BOLD);
 		wclrtoeol(alarm_win);