Re: [Mesa-dev] [PATCH 2/2] mesa: remove tabs in dri xmlconfig.c

2017-02-14 Thread Timothy Arceri

On 14/02/17 19:21, Nicolai Hähnle wrote:


Yay, style fixes :)

Does this mean you're planning to do some work on driconfig-related 
things?


I realised I should be taking notice of any driconfig options for 
shader-cache so I've added a new helper in the series I sent today. The 
helper just creates a hash of the options.


Since reading the code was causing my eyes to bleed I decided to tidy up 
while I was here.




Anyway, these patches are

Acked-by: Nicolai Hähnle 

On 13.02.2017 23:03, Timothy Arceri wrote:

---
 src/mesa/drivers/dri/common/xmlconfig.c | 724 


 1 file changed, 362 insertions(+), 362 deletions(-)

diff --git a/src/mesa/drivers/dri/common/xmlconfig.c 
b/src/mesa/drivers/dri/common/xmlconfig.c

index 4c1b345..d464937 100644
--- a/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/src/mesa/drivers/dri/common/xmlconfig.c
@@ -77,15 +77,15 @@ __getProgramName()
 static const char *progname;

 if (progname == NULL) {
-const char *e = getexecname();
-if (e != NULL) {
-/* Have to make a copy since getexecname can return a readonly
-   string, but basename expects to be able to modify its 
arg. */

-char *n = strdup(e);
-if (n != NULL) {
-progname = basename(n);
-}
-}
+const char *e = getexecname();
+if (e != NULL) {
+/* Have to make a copy since getexecname can return a 
readonly
+   string, but basename expects to be able to modify its 
arg. */

+char *n = strdup(e);
+if (n != NULL) {
+progname = basename(n);
+}
+}
 }
 return progname;
 }
@@ -126,17 +126,17 @@ findOption(const driOptionCache *cache, const 
char *name)


   /* compute a hash from the variable length name */
 for (i = 0, shift = 0; i < len; ++i, shift = (shift+8) & 31)
-hash += (uint32_t)name[i] << shift;
+hash += (uint32_t)name[i] << shift;
 hash *= hash;
 hash = (hash >> (16-cache->tableSize/2)) & mask;

   /* this is just the starting point of the linear search for the 
option */

 for (i = 0; i < size; ++i, hash = (hash+1) & mask) {
   /* if we hit an empty entry then the option is not defined 
(yet) */

-if (cache->info[hash].name == 0)
-break;
-else if (!strcmp (name, cache->info[hash].name))
-break;
+if (cache->info[hash].name == 0)
+break;
+else if (!strcmp (name, cache->info[hash].name))
+break;
 }
   /* this assertion fails if the hash table is full */
 assert (i < size);
@@ -148,8 +148,8 @@ findOption(const driOptionCache *cache, const 
char *name)

 #define XSTRDUP(dest,source) do { \
 uint32_t len = strlen (source); \
 if (!(dest = malloc(len+1))) { \
-fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); \
-abort(); \
+fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, 
__LINE__); \

+abort(); \
 } \
 memcpy (dest, source, len+1); \
 } while (0)
@@ -164,9 +164,9 @@ bsearchStr (const XML_Char *name, const XML_Char 
*elems[], uint32_t count)

 const XML_Char **found;
 found = bsearch (, elems, count, sizeof (XML_Char *), 
compare);

 if (found)
-return found - elems;
+return found - elems;
 else
-return count;
+return count;
 }

 /** \brief Locale-independent integer parser.
@@ -190,39 +190,39 @@ strToI(const XML_Char *string, const XML_Char 
**tail, int base)

 assert (radix >= 2 && radix <= 36);

 if (*string == '-') {
-sign = -1;
-string++;
+sign = -1;
+string++;
 } else if (*string == '+')
-string++;
+string++;
 if (base == 0 && *string == '0') {
-numberFound = true;
-if (*(string+1) == 'x' || *(string+1) == 'X') {
-radix = 16;
-string += 2;
-} else {
-radix = 8;
-string++;
-}
+numberFound = true;
+if (*(string+1) == 'x' || *(string+1) == 'X') {
+radix = 16;
+string += 2;
+} else {
+radix = 8;
+string++;
+}
 }
 do {
-int digit = -1;
-if (radix <= 10) {
-if (*string >= '0' && *string < '0' + radix)
-digit = *string - '0';
-} else {
-if (*string >= '0' && *string <= '9')
-digit = *string - '0';
-else if (*string >= 'a' && *string < 'a' + radix - 10)
-digit = *string - 'a' + 10;
-else if (*string >= 'A' && *string < 'A' + radix - 10)
-digit = *string - 'A' + 10;
-}
-if (digit != -1) {
-numberFound = true;
-result = radix*result + digit;
-string++;
-} else
-break;
+int digit = -1;
+if (radix <= 10) {
+if (*string >= '0' && *string < '0' + radix)
+digit = *string - '0';
+} else {
+if (*string >= '0' && *string <= '9')
+ 

Re: [Mesa-dev] [PATCH 2/2] mesa: remove tabs in dri xmlconfig.c

2017-02-14 Thread Nicolai Hähnle

Yay, style fixes :)

Does this mean you're planning to do some work on driconfig-related things?

Anyway, these patches are

Acked-by: Nicolai Hähnle 

On 13.02.2017 23:03, Timothy Arceri wrote:

---
 src/mesa/drivers/dri/common/xmlconfig.c | 724 
 1 file changed, 362 insertions(+), 362 deletions(-)

diff --git a/src/mesa/drivers/dri/common/xmlconfig.c 
b/src/mesa/drivers/dri/common/xmlconfig.c
index 4c1b345..d464937 100644
--- a/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/src/mesa/drivers/dri/common/xmlconfig.c
@@ -77,15 +77,15 @@ __getProgramName()
 static const char *progname;

 if (progname == NULL) {
-   const char *e = getexecname();
-   if (e != NULL) {
-   /* Have to make a copy since getexecname can return a readonly
-  string, but basename expects to be able to modify its arg. */
-   char *n = strdup(e);
-   if (n != NULL) {
-   progname = basename(n);
-   }
-   }
+const char *e = getexecname();
+if (e != NULL) {
+/* Have to make a copy since getexecname can return a readonly
+   string, but basename expects to be able to modify its arg. */
+char *n = strdup(e);
+if (n != NULL) {
+progname = basename(n);
+}
+}
 }
 return progname;
 }
@@ -126,17 +126,17 @@ findOption(const driOptionCache *cache, const char *name)

   /* compute a hash from the variable length name */
 for (i = 0, shift = 0; i < len; ++i, shift = (shift+8) & 31)
-   hash += (uint32_t)name[i] << shift;
+hash += (uint32_t)name[i] << shift;
 hash *= hash;
 hash = (hash >> (16-cache->tableSize/2)) & mask;

   /* this is just the starting point of the linear search for the option */
 for (i = 0; i < size; ++i, hash = (hash+1) & mask) {
   /* if we hit an empty entry then the option is not defined (yet) */
-   if (cache->info[hash].name == 0)
-   break;
-   else if (!strcmp (name, cache->info[hash].name))
-   break;
+if (cache->info[hash].name == 0)
+break;
+else if (!strcmp (name, cache->info[hash].name))
+break;
 }
   /* this assertion fails if the hash table is full */
 assert (i < size);
@@ -148,8 +148,8 @@ findOption(const driOptionCache *cache, const char *name)
 #define XSTRDUP(dest,source) do { \
 uint32_t len = strlen (source); \
 if (!(dest = malloc(len+1))) { \
-   fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); \
-   abort(); \
+fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); \
+abort(); \
 } \
 memcpy (dest, source, len+1); \
 } while (0)
@@ -164,9 +164,9 @@ bsearchStr (const XML_Char *name, const XML_Char *elems[], 
uint32_t count)
 const XML_Char **found;
 found = bsearch (, elems, count, sizeof (XML_Char *), compare);
 if (found)
-   return found - elems;
+return found - elems;
 else
-   return count;
+return count;
 }

 /** \brief Locale-independent integer parser.
@@ -190,39 +190,39 @@ strToI(const XML_Char *string, const XML_Char **tail, int 
base)
 assert (radix >= 2 && radix <= 36);

 if (*string == '-') {
-   sign = -1;
-   string++;
+sign = -1;
+string++;
 } else if (*string == '+')
-   string++;
+string++;
 if (base == 0 && *string == '0') {
-   numberFound = true;
-   if (*(string+1) == 'x' || *(string+1) == 'X') {
-   radix = 16;
-   string += 2;
-   } else {
-   radix = 8;
-   string++;
-   }
+numberFound = true;
+if (*(string+1) == 'x' || *(string+1) == 'X') {
+radix = 16;
+string += 2;
+} else {
+radix = 8;
+string++;
+}
 }
 do {
-   int digit = -1;
-   if (radix <= 10) {
-   if (*string >= '0' && *string < '0' + radix)
-   digit = *string - '0';
-   } else {
-   if (*string >= '0' && *string <= '9')
-   digit = *string - '0';
-   else if (*string >= 'a' && *string < 'a' + radix - 10)
-   digit = *string - 'a' + 10;
-   else if (*string >= 'A' && *string < 'A' + radix - 10)
-   digit = *string - 'A' + 10;
-   }
-   if (digit != -1) {
-   numberFound = true;
-   result = radix*result + digit;
-   string++;
-   } else
-   break;
+int digit = -1;
+if (radix <= 10) {
+if (*string >= '0' && *string < '0' + radix)
+digit = *string - '0';
+} else {
+if (*string >= '0' && *string <= '9')
+digit = *string - '0';
+else if (*string >= 'a' && *string < 'a' + radix - 10)
+digit = *string - 'a' + 10;
+else if (*string >= 'A' &&