This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use correct signedness in wcsncmp.




On 04/07/2015 11:55 AM, Andreas Schwab wrote:
Stefan Liebler <stli@linux.vnet.ibm.com> writes:

@@ -82,12 +154,12 @@ do_test_limit (size_t align1, size_t align2, size_t len, size_t n, int max_char,
  	 int exp_result)
  {
    size_t i, align_n;
-  char *s1, *s2;
+  CHAR *s1, *s2;

    if (n == 0)
      {
-      s1 = (char*)(buf1 + page_size);
-      s2 = (char*)(buf2 + page_size);
+      s1 = (CHAR*)(buf1 + page_size);
+      s2 = (CHAR*)(buf2 + page_size);

Please add a space before '*' and after the cast.

    if (align1 < align_n)
-    s1 -= (align_n - align1);
+    s1 = (CHAR*) (((char*)s1) - (align_n - align1));

Please remove the redundant parens around the cast expression.

Andreas.

I have changed the patch.
Bye.

---
2015-04-07  Stefan Liebler  <stli@linux.vnet.ibm.com>

	* wcsmbs/wcsncmp.c (wcsncmp): Compare as wchar_t, not wint_t.
	  Use signed comparision instead of substraction to avoid
	  overflow bug.
	* localedata/tests-mbwc/tst_wcsncmp.c (tst_wcsncmp):
	  Take the sign of ret.
	* localedata/tests-mbwc/dat_wcsncmp.c (tst_wcsncmp_loc):
	  Do not expect precise return values. Only the sign matters.
	* wcsmbs/Makefile (strop-tests): Add wcsncmp.
	* wcsmbs/test-wcsncmp.c: New File.
	* string/test-strncmp.c: Add wcsncmp support.

Attachment: wcsncmp_07042015
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]